mlf176f2 pushed a commit to branch externals/ergoemacs-mode in repository elpa.
commit ed131be2e1c63a083d8c2576bfc35007908e517d Author: Matthew L. Fidler <[email protected]> Date: Fri May 23 18:19:04 2014 +0800 Took out unknown signatory advice :(. Cleaned up advices. --- ergoemacs-advices.el | 62 +++++-------------------------------------------- 1 files changed, 7 insertions(+), 55 deletions(-) diff --git a/ergoemacs-advices.el b/ergoemacs-advices.el index e5a186c..5b2c57c 100644 --- a/ergoemacs-advices.el +++ b/ergoemacs-advices.el @@ -38,13 +38,14 @@ "Ergoemacs directory.") (add-to-list 'load-path ergoemacs-dir) (require 'ergoemacs-shortcuts) +(require 'ergoemacs-unbind) (defmacro ergoemacs-define-overrides (&rest body) "Force the define-keys to work" `(let ((ergoemacs-run-mode-hooks t)) ,@body)) -(defadvice add-hook (around ergoemacs-add-hook-advice (hook function &optional append local)) +(defadvice add-hook (around ergoemacs-add-hook-advice (hook function &optional append local) activate) "Advice to allow `this-command' to be set correctly before running `pre-command-hook' If `pre-command-hook' is used and `ergoemacs-mode' is enabled add to `ergoemacs-pre-command-hook' instead." (cond @@ -55,9 +56,8 @@ If `pre-command-hook' is used and `ergoemacs-mode' is enabled add to `ergoemacs- (add-hook 'ergoemacs-pre-command-hook function append local)) (t ad-do-it))) -(ad-activate 'add-hook) -(defadvice remove-hook (around ergoemacs-remove-hook-advice (hook function &optional local)) +(defadvice remove-hook (around ergoemacs-remove-hook-advice (hook function &optional local) activate) "Advice to allow `this-command' to be set correctly before running `pre-command-hook'. If `pre-command-hook' is used and `ergoemacs-mode' is remove from `ergoemacs-pre-command-hook' instead." (cond @@ -68,9 +68,8 @@ If `pre-command-hook' is used and `ergoemacs-mode' is remove from `ergoemacs-pre (remove-hook 'ergoemacs-pre-command-hook function local)) (t ad-do-it))) -(ad-activate 'remove-hook) -(defadvice define-key (around ergoemacs-define-key-advice (keymap key def)) +(defadvice define-key (around ergoemacs-define-key-advice (keymap key def) activate) "This does the right thing when modifying `ergoemacs-keymap'. Also adds keymap-flag for user-defined keys run with `run-mode-hooks'." (let ((is-global-p (equal keymap (current-global-map)))) @@ -90,7 +89,6 @@ Also adds keymap-flag for user-defined keys run with `run-mode-hooks'." (unless (vectorp vk) ;; Do vector def too. (setq vk (read-kbd-macro (key-description key) t)) (ergoemacs-global-set-key-after vk def)))))) -(ad-activate 'define-key) (defvar ergoemacs-global-override-rm-keys '()) ;;; Advices enabled or disabled with ergoemacs-mode @@ -108,12 +106,11 @@ Also adds keymap-flag for user-defined keys run with `run-mode-hooks'." (when (and (boundp 'ergoemacs-mode) ergoemacs-mode) (ergoemacs-theme-remove-key-list (list key) t)))))) -(defadvice local-set-key (around ergoemacs-local-set-key-advice (key command)) +(defadvice local-set-key (around ergoemacs-local-set-key-advice (key command) activate) "This let you use `local-set-key' as usual when `ergoemacs-mode' is enabled." (if (and (fboundp 'ergoemacs-mode) ergoemacs-mode) (ergoemacs-local-set-key key command) ad-do-it)) - (add-to-list 'ergoemacs-advices 'ergoemacs-local-set-key-advice) (defadvice local-unset-key (around ergoemacs-local-unset-key-advice (key)) @@ -220,63 +217,18 @@ This require `ergoemacs-mode' to be enabled as well as (ad-activate 'helm-ff-auto-expand-to-home-or-root))) -(defadvice run-mode-hooks (around ergoemacs-run-hooks) +(defadvice run-mode-hooks (around ergoemacs-run-hooks activate) "`ergoemacs-mode' run-hooks advice helps user define keys properly. This assumes any key defined while running a hook is a user-defined hook." (let ((ergoemacs-run-mode-hooks t)) ad-do-it)) -(ad-activate 'run-mode-hooks) -(defadvice turn-on-undo-tree-mode (around ergoemacs-undo-tree-mode) +(defadvice turn-on-undo-tree-mode (around ergoemacs-undo-tree-mode activate) "Make `ergoemacs-mode' and undo-tree compatible." (ergoemacs-with-global ad-do-it)) -(ad-activate 'turn-on-undo-tree-mode) - -(defcustom ergoemacs-check-new-buffer-auto-mode 't - "Check `auto-mode-alist' for major mode for just created new buffer. -If nil - use value of `major-mode'." - :group 'ergoemacs-mode - :type 'boolean) -(defadvice set-buffer-major-mode (after ergoemacs-new-buffer-auto-mode activate compile) - "Select major mode for newly created buffer. -Compare the `buffer-name' the entries in `auto-mode-alist'." - (when ergoemacs-check-new-buffer-auto-mode - (with-current-buffer (ad-get-arg 0) - (if (and (buffer-name) (not buffer-file-name)) - (let ((name (buffer-name)) mode) - ;; Remove backup-suffixes from file name. - (setq name (file-name-sans-versions name)) - ;; Do not handle service buffers - (while (and name (not (string-match "^\\*.+\\*$" name))) - ;; Find first matching alist entry. - (setq mode - (if (memq system-type '(windows-nt cygwin)) - ;; System is case-insensitive. - (let ((case-fold-search t)) - (assoc-default name auto-mode-alist - 'string-match)) - ;; System is case-sensitive. - (or - ;; First match case-sensitively. - (let ((case-fold-search nil)) - (assoc-default name auto-mode-alist - 'string-match)) - ;; Fallback to case-insensitive match. - (and auto-mode-case-fold - (let ((case-fold-search t)) - (assoc-default name auto-mode-alist - 'string-match)))))) - (if (and mode - (consp mode) - (cadr mode)) - (setq mode (car mode) - name (substring name 0 (match-beginning 0))) - (setq name nil)) - (when mode - (set-auto-mode-0 mode t)))))))) (provide 'ergoemacs-advices)
