Commit 98c8955a authored by Duncan Bayne's avatar Duncan Bayne

Switch to forward-slashes for namespacing Elisp

parent f5ff6951
...@@ -11,15 +11,15 @@ ...@@ -11,15 +11,15 @@
(server-start) (server-start)
;; load ~/emacs.d/??-*.el in numerical order ;; load ~/emacs.d/??-*.el in numerical order
(defvar utils:sorted-absolute-init-scripts) (defvar utils/sorted-absolute-init-scripts)
(let* ((emacs-dir (file-name-as-directory "~/.emacs.d")) (let* ((emacs-dir (file-name-as-directory "~/.emacs.d"))
(default-directory emacs-dir) (default-directory emacs-dir)
(init-scripts (file-expand-wildcards "??-*.el")) (init-scripts (file-expand-wildcards "??-*.el"))
(sorted-init-scripts (sort init-scripts 'string=))) (sorted-init-scripts (sort init-scripts 'string=)))
(setq utils:sorted-absolute-init-scripts (setq utils/sorted-absolute-init-scripts
(mapcar (lambda (name) (concat emacs-dir name)) sorted-init-scripts))) (mapcar (lambda (name) (concat emacs-dir name)) sorted-init-scripts)))
(mapcar #'load utils:sorted-absolute-init-scripts) (mapcar #'load utils/sorted-absolute-init-scripts)
(put 'erase-buffer 'disabled nil) (put 'erase-buffer 'disabled nil)
;; prevent accidental shutdown; can still use 'M-x save-buffers-kill-terminal' ;; prevent accidental shutdown; can still use 'M-x save-buffers-kill-terminal'
......
...@@ -5,14 +5,14 @@ ...@@ -5,14 +5,14 @@
(setq multi-term-program "zsh") (setq multi-term-program "zsh")
(defun utils:add-to-load-path (path-list) (defun utils/add-to-load-path (path-list)
"Adds each path in path-list to the load path." "Adds each path in path-list to the load path."
(mapcar (mapcar
(lambda (path) (lambda (path)
(add-to-list 'load-path path)) (add-to-list 'load-path path))
path-list)) path-list))
(defun utils:change-all-terminal-dirs (new-directory) (defun utils/change-all-terminal-dirs (new-directory)
"Changes the default directory for every buffer that is a terminal." "Changes the default directory for every buffer that is a terminal."
(interactive (list (read-directory-name "New directory:"))) (interactive (list (read-directory-name "New directory:")))
(mapcar (mapcar
...@@ -26,12 +26,12 @@ ...@@ -26,12 +26,12 @@
(term-send-raw-string (concat "cd " new-directory "\n")))))) (term-send-raw-string (concat "cd " new-directory "\n"))))))
(buffer-list))) (buffer-list)))
(defun utils:create-or-switch-to-term (terminal-name) (defun utils/create-or-switch-to-term (terminal-name)
"Creates or switches to a named terminal, earmuffing the name if it isn't already." "Creates or switches to a named terminal, earmuffing the name if it isn't already."
(interactive (list (ido-completing-read "Switch to term buffer: " (utils:term-buffer-names)))) (interactive (list (ido-completing-read "Switch to term buffer: " (utils/term-buffer-names))))
(if (string= "" terminal-name) (if (string= "" terminal-name)
(message "Refusing to create buffer with empty name") (message "Refusing to create buffer with empty name")
(let ((new-buffer-name (utils:earmuffenate terminal-name))) (let ((new-buffer-name (utils/earmuffenate terminal-name)))
(if (get-buffer new-buffer-name) (if (get-buffer new-buffer-name)
(switch-to-buffer new-buffer-name) (switch-to-buffer new-buffer-name)
(progn (progn
...@@ -39,15 +39,15 @@ ...@@ -39,15 +39,15 @@
(set-buffer (multi-term)) (set-buffer (multi-term))
(rename-buffer new-buffer-name)))))) (rename-buffer new-buffer-name))))))
(defun utils:create-terminals (terminal-names) (defun utils/create-terminals (terminal-names)
"Creates terminals with the specified names using multi-term." "Creates terminals with the specified names using multi-term."
(require 'multi-term) (require 'multi-term)
(mapcar (mapcar
(lambda (desired-name) (lambda (desired-name)
(utils:create-or-switch-to-term desired-name)) (utils/create-or-switch-to-term desired-name))
terminal-names)) terminal-names))
(defun utils:earmuffenate (name) (defun utils/earmuffenate (name)
"Surrounds name with earmuffs, if it isn't already." "Surrounds name with earmuffs, if it isn't already."
(let ((new-name name)) (let ((new-name name))
(if (not (string-prefix-p "*" new-name)) (if (not (string-prefix-p "*" new-name))
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
(setq new-name (concat new-name "*"))) (setq new-name (concat new-name "*")))
new-name)) new-name))
(defun utils:kill-unmodified-buffers () (defun utils/kill-unmodified-buffers ()
"Kill any unmodifier buffers that are inspecting files." "Kill any unmodifier buffers that are inspecting files."
(interactive) (interactive)
(mapcar (mapcar
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
(kill-buffer buf))) (kill-buffer buf)))
(buffer-list))) (buffer-list)))
(defun utils:kill-other-unmodified-buffers () (defun utils/kill-other-unmodified-buffers ()
"Kill any unmodifier buffers that are inspecting files, except for the current buffer." "Kill any unmodifier buffers that are inspecting files, except for the current buffer."
(interactive) (interactive)
(mapcar (mapcar
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
(kill-buffer buf))) (kill-buffer buf)))
(buffer-list))) (buffer-list)))
(defun utils:set-mode (mode filename-pattern-list) (defun utils/set-mode (mode filename-pattern-list)
"Sets the specified mode for each filename pattern in filename-pattern-list." "Sets the specified mode for each filename pattern in filename-pattern-list."
(mapcar (mapcar
(lambda (filename-pattern) (lambda (filename-pattern)
...@@ -86,62 +86,62 @@ ...@@ -86,62 +86,62 @@
(cons (cons filename-pattern mode) auto-mode-alist))) (cons (cons filename-pattern mode) auto-mode-alist)))
filename-pattern-list)) filename-pattern-list))
(defun utils:term-buffers () (defun utils/term-buffers ()
"Returns all buffers that are terminals." "Returns all buffers that are terminals."
(remove-if-not (remove-if-not
#'nil #'nil
(mapcar (mapcar
(lambda (buffer) (if (utils:term-p buffer) buffer nil)) (lambda (buffer) (if (utils/term-p buffer) buffer nil))
(buffer-list)))) (buffer-list))))
(defun utils:term-buffer-names () (defun utils/term-buffer-names ()
"Returns the names of all buffers that are terminals." "Returns the names of all buffers that are terminals."
(mapcar #'buffer-name (utils:term-buffers))) (mapcar #'buffer-name (utils/term-buffers)))
(defun utils:term-p (buffer) (defun utils/term-p (buffer)
"Returns t if buffer is a terminal, nil otherwise." "Returns t if buffer is a terminal, nil otherwise."
(equal 'term-mode (buffer-local-value 'major-mode buffer))) (equal 'term-mode (buffer-local-value 'major-mode buffer)))
(defun utils:region-string () (defun utils/region-string ()
"Returns a string containing the currently selected region." "Returns a string containing the currently selected region."
(buffer-substring (mark) (point))) (buffer-substring (mark) (point)))
(defun utils:visit-buffer-named-in-region () (defun utils/visit-buffer-named-in-region ()
"Opens the file named in the currently selected region." "Opens the file named in the currently selected region."
(interactive) (interactive)
(find-file (utils:region-string))) (find-file (utils/region-string)))
(defun utils:display-ansi-colors () (defun utils/display-ansi-colors ()
"Replaces all ANSI color sequences in current buffer with actual colors." "Replaces all ANSI color sequences in current buffer with actual colors."
(interactive) (interactive)
(let ((inhibit-read-only t)) (let ((inhibit-read-only t))
(ansi-color-apply-on-region (point-min) (point-max)))) (ansi-color-apply-on-region (point-min) (point-max))))
(defun utils:ensure-syncthing-running () (defun utils/ensure-syncthing-running ()
"Ensures syncthing is running." "Ensures syncthing is running."
(interactive) (interactive)
(if (not (member "*syncthing*" (utils:term-buffer-names))) (if (not (member "*syncthing*" (utils/term-buffer-names)))
(progn (progn
(utils:create-or-switch-to-term "syncthing") (utils/create-or-switch-to-term "syncthing")
(cd "~") (cd "~")
(term-send-raw-string "killall syncthing\n") (term-send-raw-string "killall syncthing\n")
(term-send-raw-string "syncthing\n")))) (term-send-raw-string "syncthing\n"))))
(defun utils:ensure-syncthing-stopped () (defun utils/ensure-syncthing-stopped ()
"Ensures syncthing is not running." "Ensures syncthing is not running."
(interactive) (interactive)
(if (member "*syncthing*" (utils:term-buffer-names)) (if (member "*syncthing*" (utils/term-buffer-names))
(progn (progn
(shell-command "killall syncthing") (shell-command "killall syncthing")
(utils:create-or-switch-to-term "syncthing") (utils/create-or-switch-to-term "syncthing")
(term-send-raw-string "exit\n")))) (term-send-raw-string "exit\n"))))
(defun utils:safe-shell-command (command) (defun utils/safe-shell-command (command)
"Runs a shell command, and raises an error if it fails." "Runs a shell command, and raises an error if it fails."
(if (not (= 0 (shell-command command))) (if (not (= 0 (shell-command command)))
(error (concat "shell-command failed: " command)))) (error (concat "shell-command failed: " command))))
(defun utils:cd (directory-name) (defun utils/cd (directory-name)
"Prompt user to enter a string, with input history support." "Prompt user to enter a string, with input history support."
(interactive (interactive
(list (list
...@@ -149,7 +149,7 @@ ...@@ -149,7 +149,7 @@
(term-send-raw-string (concat "cd " directory-name "\n")) (term-send-raw-string (concat "cd " directory-name "\n"))
(cd directory-name)) (cd directory-name))
(defun utils:atlas () (defun utils/atlas ()
"Inserts a Unicode shrug" "Inserts a Unicode shrug"
(interactive) (interactive)
(insert "¯\\_(ツ)_/¯")) (insert "¯\\_(ツ)_/¯"))
...@@ -163,3 +163,13 @@ ...@@ -163,3 +163,13 @@
(when filename (when filename
(kill-new filename) (kill-new filename)
(message "Copied buffer file name '%s' to the clipboard." filename)))) (message "Copied buffer file name '%s' to the clipboard." filename))))
(defun utils/insert-date ()
"Insert the current date in org-mode format (YYYY-MM-DD DAY)."
(interactive)
(insert (format-time-string "%Y-%m-%d %a")))
(defun utils/insert-date-time ()
"Insert the current datetime in org-mode format (YYYY-MM-DD DAY HH:MM)."
(interactive)
(insert (format-time-string "%Y-%m-%d %a %H:%M ")))
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
;; + http://xahlee.org/emacs/emacs_make_modern.html ;; + http://xahlee.org/emacs/emacs_make_modern.html
;; ;;
(utils:add-to-load-path '("~/.emacs.d/ws-trim")) (utils/add-to-load-path '("~/.emacs.d/ws-trim"))
(require 'avy) (require 'avy)
(require 'company) (require 'company)
...@@ -83,14 +83,14 @@ ...@@ -83,14 +83,14 @@
(global-set-key (kbd "C-+") 'text-scale-increase) (global-set-key (kbd "C-+") 'text-scale-increase)
(global-set-key (kbd "C--") 'text-scale-decrease) (global-set-key (kbd "C--") 'text-scale-decrease)
(global-set-key (kbd "C-c M-s") 'utils:atlas) (global-set-key (kbd "C-c M-s") 'utils/atlas)
(global-set-key (kbd "C-c RET") 'utils:cd) (global-set-key (kbd "C-c RET") 'utils/cd)
(global-set-key (kbd "C-x C-r") 'sudo-edit) (global-set-key (kbd "C-x C-r") 'sudo-edit)
(global-set-key (kbd "C-x M-a") 'utils:display-ansi-colors) (global-set-key (kbd "C-x M-a") 'utils/display-ansi-colors)
(global-set-key (kbd "C-x w") 'elfeed) (global-set-key (kbd "C-x w") 'elfeed)
(global-set-key (kbd "M-s") 'avy-goto-word-1) (global-set-key (kbd "M-s") 'avy-goto-word-1)
(global-set-key (kbd "s-b") 'browse-url-at-point) (global-set-key (kbd "s-b") 'browse-url-at-point)
(global-set-key (kbd "s-f") 'utils:visit-buffer-named-in-region) (global-set-key (kbd "s-f") 'utils/visit-buffer-named-in-region)
(global-set-key (kbd "s-q") 'magit-status) (global-set-key (kbd "s-q") 'magit-status)
(global-set-key (kbd "s-s") 'floobits-summon) (global-set-key (kbd "s-s") 'floobits-summon)
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
'(jabber-auto-reconnect t) '(jabber-auto-reconnect t)
'(package-selected-packages '(package-selected-packages
(quote (quote
(zenburn-theme yari yaml-mode web-mode w3m tomatinho smartparens slime slack scala-mode2 sass-mode rspec-mode robe restclient quack ps-ccrypt persistent-scratch org-present neotree multi-term markdown-mode magit lua-mode js2-mode jabber inform7-mode ido-vertical-mode hexrgb helm-open-github handlebars-mode graphviz-dot-mode gradle-mode google-this go-mode git-rebase-mode git-commit-mode format-sql flycheck-color-mode-line flycheck-clojure flx-ido floobits flim find-file-in-project feature-mode evil ess eruby-mode elnode elfeed editorconfig-core editorconfig dumb-jump dockerfile-mode diffview diff-hl cypher-mode csv-nav counsel-projectile company-shell company-emoji company-emacs-eclim company-cmake company-c-headers color-theme coffee-mode bbdb-vcard avy ag ac-geiser)))) (origami typescript-mode rubocop zenburn-theme yari yaml-mode web-mode w3m tomatinho smartparens slime slack scala-mode2 sass-mode rspec-mode robe restclient quack ps-ccrypt persistent-scratch org-present neotree multi-term markdown-mode magit lua-mode js2-mode jabber inform7-mode ido-vertical-mode hexrgb helm-open-github handlebars-mode graphviz-dot-mode gradle-mode google-this go-mode git-rebase-mode git-commit-mode format-sql flycheck-color-mode-line flycheck-clojure flx-ido floobits flim find-file-in-project feature-mode evil ess eruby-mode elnode elfeed editorconfig-core editorconfig dumb-jump dockerfile-mode diffview diff-hl cypher-mode csv-nav counsel-projectile company-shell company-emoji company-emacs-eclim company-cmake company-c-headers color-theme coffee-mode bbdb-vcard avy ag ac-geiser))))
(custom-set-faces (custom-set-faces
;; custom-set-faces was added by Custom. ;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful. ;; If you edit it by hand, you could mess it up, so be careful.
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
;; + http://stackoverflow.com/users/523044/tyler ;; + http://stackoverflow.com/users/523044/tyler
;; ;;
(utils:add-to-load-path '("~/.emacs.d/yari.el")) (utils/add-to-load-path '("~/.emacs.d/yari.el"))
(require 'company) (require 'company)
(require 'company-robe) (require 'company-robe)
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
(global-font-lock-mode 1) (global-font-lock-mode 1)
(autoload 'ruby-mode "ruby-mode" "Ruby editing mode." t) (autoload 'ruby-mode "ruby-mode" "Ruby editing mode." t)
(utils:set-mode (utils/set-mode
'ruby-mode 'ruby-mode
'("Gemfile$" '("Gemfile$"
"\\.gemspec$" "\\.gemspec$"
...@@ -36,9 +36,9 @@ ...@@ -36,9 +36,9 @@
(add-hook 'robe-mode-hook 'ac-robe-setup) (add-hook 'robe-mode-hook 'ac-robe-setup)
(autoload 'feature-mode "feature-mode" "Cucumber feature editing mode." t) (autoload 'feature-mode "feature-mode" "Cucumber feature editing mode." t)
(utils:set-mode 'feature-mode '("\\.feature$")) (utils/set-mode 'feature-mode '("\\.feature$"))
(utils:set-mode 'yaml-mode '("\\.yml$")) (utils/set-mode 'yaml-mode '("\\.yml$"))
(add-hook 'yaml-mode-hook '(lambda () (define-key yaml-mode-map "\C-m" 'newline-and-indent))) (add-hook 'yaml-mode-hook '(lambda () (define-key yaml-mode-map "\C-m" 'newline-and-indent)))
(autoload 'markdown-mode "markdown-mode" (autoload 'markdown-mode "markdown-mode"
......
...@@ -5,21 +5,21 @@ ...@@ -5,21 +5,21 @@
(require 'web-mode) (require 'web-mode)
(setq coffee-tab-width 2) (setq coffee-tab-width 2)
(utils:set-mode 'coffee-mode '("\\.coffee$")) (utils/set-mode 'coffee-mode '("\\.coffee$"))
(utils:set-mode (utils/set-mode
'css-mode 'css-mode
'("\\.css$" '("\\.css$"
"\\.scss$")) "\\.scss$"))
(utils:set-mode (utils/set-mode
'haml-mode 'haml-mode
'("\\.haml$" '("\\.haml$"
"\\.hamlc$" "\\.hamlc$"
"\\.hamljs$")) "\\.hamljs$"))
(utils:set-mode 'sass-mode '("\\.sass$")) (utils/set-mode 'sass-mode '("\\.sass$"))
(utils:set-mode 'web-mode '("\\.[agj]sp\\'" (utils/set-mode 'web-mode '("\\.[agj]sp\\'"
"\\.as[cp]x\\'" "\\.as[cp]x\\'"
"\\.djhtml\\'" "\\.djhtml\\'"
"\\.erb\\'" "\\.erb\\'"
......
(autoload 'inform-mode "inform-mode" "Inform editing mode." t) (autoload 'inform-mode "inform-mode" "Inform editing mode." t)
(autoload 'inform-maybe-mode "inform-mode" "Inform/C header editing mode.") (autoload 'inform-maybe-mode "inform-mode" "Inform/C header editing mode.")
(utils:set-mode 'inform-maybe-mode '("\\.h\\'")) (utils/set-mode 'inform-maybe-mode '("\\.h\\'"))
(utils:set-mode 'inform-mode '("\\.inf\\'")) (utils/set-mode 'inform-mode '("\\.inf\\'"))
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
;; + https://www.emacswiki.org/emacs/ErcSASL ;; + https://www.emacswiki.org/emacs/ErcSASL
;; ;;
(utils:add-to-load-path '("~/.emacs.d/emotion-iconous-mode")) (utils/add-to-load-path '("~/.emacs.d/emotion-iconous-mode"))
(utils:add-to-load-path '("~/.emacs.d/erc-sasl")) (utils/add-to-load-path '("~/.emacs.d/erc-sasl"))
(require 'emotion-iconous-mode) (require 'emotion-iconous-mode)
(require 'erc) (require 'erc)
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
(turn-on-auto-fill)) (turn-on-auto-fill))
(add-hook 'message-mode-hook 'my-message-mode-setup) (add-hook 'message-mode-hook 'my-message-mode-setup)
(utils:set-mode (utils/set-mode
'mail-mode 'mail-mode
'("\\.eml$")) '("\\.eml$"))
(add-hook 'mail-mode-hook 'auto-fill-mode) (add-hook 'mail-mode-hook 'auto-fill-mode)
(if (and (if (and
(not (equal system-type 'windows-nt))) (not (equal system-type 'windows-nt)))
(utils:create-terminals (utils/create-terminals
'("tests" '("tests"
"server" "server"
"guard" "guard"
"misc"))) "misc")))
(global-set-key (kbd "C-x c") 'utils:create-or-switch-to-term) (global-set-key (kbd "C-x c") 'utils/create-or-switch-to-term)
(utils:set-mode (utils/set-mode
'cypher-mode 'cypher-mode
'("\\.cql$")) '("\\.cql$"))
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
;; Thanks to: ;; Thanks to:
;; + http://www.arminsadeghi.com/slickedit_and_emacs ;; + http://www.arminsadeghi.com/slickedit_and_emacs
;; + http://unix.stackexchange.com/a/146781 ;; + http://unix.stackexchange.com/a/146781
;; + http://pragmaticemacs.com/emacs/adaptive-cursor-width/
;; ;;
(when window-system (when window-system
...@@ -27,3 +28,5 @@ ...@@ -27,3 +28,5 @@
(load-theme 'zenburn t) (load-theme 'zenburn t)
(set-face-attribute 'default nil :height 100) (set-face-attribute 'default nil :height 100)
(setq x-stretch-cursor t)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment