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

Switch to forward-slashes for namespacing Elisp

parent f5ff6951
......@@ -11,15 +11,15 @@
(server-start)
;; 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"))
(default-directory emacs-dir)
(init-scripts (file-expand-wildcards "??-*.el"))
(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 #'load utils:sorted-absolute-init-scripts)
(mapcar #'load utils/sorted-absolute-init-scripts)
(put 'erase-buffer 'disabled nil)
;; prevent accidental shutdown; can still use 'M-x save-buffers-kill-terminal'
......
......@@ -5,14 +5,14 @@
(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."
(mapcar
(lambda (path)
(add-to-list 'load-path path))
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."
(interactive (list (read-directory-name "New directory:")))
(mapcar
......@@ -26,12 +26,12 @@
(term-send-raw-string (concat "cd " new-directory "\n"))))))
(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."
(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)
(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)
(switch-to-buffer new-buffer-name)
(progn
......@@ -39,15 +39,15 @@
(set-buffer (multi-term))
(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."
(require 'multi-term)
(mapcar
(lambda (desired-name)
(utils:create-or-switch-to-term desired-name))
(utils/create-or-switch-to-term desired-name))
terminal-names))
(defun utils:earmuffenate (name)
(defun utils/earmuffenate (name)
"Surrounds name with earmuffs, if it isn't already."
(let ((new-name name))
(if (not (string-prefix-p "*" new-name))
......@@ -56,7 +56,7 @@
(setq new-name (concat new-name "*")))
new-name))
(defun utils:kill-unmodified-buffers ()
(defun utils/kill-unmodified-buffers ()
"Kill any unmodifier buffers that are inspecting files."
(interactive)
(mapcar
......@@ -65,7 +65,7 @@
(kill-buffer buf)))
(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."
(interactive)
(mapcar
......@@ -77,7 +77,7 @@
(kill-buffer buf)))
(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."
(mapcar
(lambda (filename-pattern)
......@@ -86,62 +86,62 @@
(cons (cons filename-pattern mode) auto-mode-alist)))
filename-pattern-list))
(defun utils:term-buffers ()
(defun utils/term-buffers ()
"Returns all buffers that are terminals."
(remove-if-not
#'nil
(mapcar
(lambda (buffer) (if (utils:term-p buffer) buffer nil))
(lambda (buffer) (if (utils/term-p buffer) buffer nil))
(buffer-list))))
(defun utils:term-buffer-names ()
(defun utils/term-buffer-names ()
"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."
(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."
(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."
(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."
(interactive)
(let ((inhibit-read-only t))
(ansi-color-apply-on-region (point-min) (point-max))))
(defun utils:ensure-syncthing-running ()
(defun utils/ensure-syncthing-running ()
"Ensures syncthing is running."
(interactive)
(if (not (member "*syncthing*" (utils:term-buffer-names)))
(if (not (member "*syncthing*" (utils/term-buffer-names)))
(progn
(utils:create-or-switch-to-term "syncthing")
(utils/create-or-switch-to-term "syncthing")
(cd "~")
(term-send-raw-string "killall syncthing\n")
(term-send-raw-string "syncthing\n"))))
(defun utils:ensure-syncthing-stopped ()
(defun utils/ensure-syncthing-stopped ()
"Ensures syncthing is not running."
(interactive)
(if (member "*syncthing*" (utils:term-buffer-names))
(if (member "*syncthing*" (utils/term-buffer-names))
(progn
(shell-command "killall syncthing")
(utils:create-or-switch-to-term "syncthing")
(utils/create-or-switch-to-term "syncthing")
(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."
(if (not (= 0 (shell-command 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."
(interactive
(list
......@@ -149,7 +149,7 @@
(term-send-raw-string (concat "cd " directory-name "\n"))
(cd directory-name))
(defun utils:atlas ()
(defun utils/atlas ()
"Inserts a Unicode shrug"
(interactive)
(insert "¯\\_(ツ)_/¯"))
......@@ -163,3 +163,13 @@
(when filename
(kill-new 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 @@
;; + 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 'company)
......@@ -83,14 +83,14 @@
(global-set-key (kbd "C-+") 'text-scale-increase)
(global-set-key (kbd "C--") 'text-scale-decrease)
(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 M-s") 'utils/atlas)
(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 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 "M-s") 'avy-goto-word-1)
(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-s") 'floobits-summon)
......
......@@ -9,7 +9,7 @@
'(jabber-auto-reconnect t)
'(package-selected-packages
(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 was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
......
......@@ -6,7 +6,7 @@
;; + 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-robe)
......@@ -17,7 +17,7 @@
(global-font-lock-mode 1)
(autoload 'ruby-mode "ruby-mode" "Ruby editing mode." t)
(utils:set-mode
(utils/set-mode
'ruby-mode
'("Gemfile$"
"\\.gemspec$"
......@@ -36,9 +36,9 @@
(add-hook 'robe-mode-hook 'ac-robe-setup)
(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)))
(autoload 'markdown-mode "markdown-mode"
......
......@@ -5,21 +5,21 @@
(require 'web-mode)
(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$"
"\\.scss$"))
(utils:set-mode
(utils/set-mode
'haml-mode
'("\\.haml$"
"\\.hamlc$"
"\\.hamljs$"))
(utils:set-mode 'sass-mode '("\\.sass$"))
(utils:set-mode 'web-mode '("\\.[agj]sp\\'"
(utils/set-mode 'sass-mode '("\\.sass$"))
(utils/set-mode 'web-mode '("\\.[agj]sp\\'"
"\\.as[cp]x\\'"
"\\.djhtml\\'"
"\\.erb\\'"
......
(autoload 'inform-mode "inform-mode" "Inform editing mode." t)
(autoload 'inform-maybe-mode "inform-mode" "Inform/C header editing mode.")
(utils:set-mode 'inform-maybe-mode '("\\.h\\'"))
(utils:set-mode 'inform-mode '("\\.inf\\'"))
(utils/set-mode 'inform-maybe-mode '("\\.h\\'"))
(utils/set-mode 'inform-mode '("\\.inf\\'"))
......@@ -3,8 +3,8 @@
;; + https://www.emacswiki.org/emacs/ErcSASL
;;
(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/emotion-iconous-mode"))
(utils/add-to-load-path '("~/.emacs.d/erc-sasl"))
(require 'emotion-iconous-mode)
(require 'erc)
......@@ -34,7 +34,7 @@
(turn-on-auto-fill))
(add-hook 'message-mode-hook 'my-message-mode-setup)
(utils:set-mode
(utils/set-mode
'mail-mode
'("\\.eml$"))
(add-hook 'mail-mode-hook 'auto-fill-mode)
(if (and
(not (equal system-type 'windows-nt)))
(utils:create-terminals
(utils/create-terminals
'("tests"
"server"
"guard"
"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
'("\\.cql$"))
......@@ -2,6 +2,7 @@
;; Thanks to:
;; + http://www.arminsadeghi.com/slickedit_and_emacs
;; + http://unix.stackexchange.com/a/146781
;; + http://pragmaticemacs.com/emacs/adaptive-cursor-width/
;;
(when window-system
......@@ -27,3 +28,5 @@
(load-theme 'zenburn t)
(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