From 6a4c51287f68d62eb0b9eee5500f5c05ca7ee53b Mon Sep 17 00:00:00 2001 From: Roland Walker Date: Mon, 20 Aug 2012 14:33:34 -0400 Subject: [PATCH 1/2] set this-command along with current-prefix-arg --- smex.el | 1 + 1 file changed, 1 insertion(+) diff --git a/smex.el b/smex.el index e2e0fd9..82caf09 100644 --- a/smex.el +++ b/smex.el @@ -105,6 +105,7 @@ Set this to nil to disable fuzzy matching." (funcall action chosen-item)) (unwind-protect (progn (setq prefix-arg current-prefix-arg) + (setq this-command chosen-item) (command-execute chosen-item 'record)) (smex-rank chosen-item) (smex-show-key-advice chosen-item) From f21e593022fe7968b5b821a04a012730d546125d Mon Sep 17 00:00:00 2001 From: Roland Walker Date: Tue, 21 Aug 2012 19:46:42 -0400 Subject: [PATCH 2/2] Filter unwanted commands from the smex prompt Removing: obsolete commands advice forms menu-bar commands mouse-interactive commands (imperfect, but no false positives) Adding the ability to mark a command to be filtered from the prompt by setting the 'smex-ignore property. --- smex.el | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/smex.el b/smex.el index 82caf09..51d249d 100644 --- a/smex.el +++ b/smex.el @@ -174,7 +174,34 @@ Set this to nil to disable fuzzy matching." (setq smex-ido-cache (smex-convert-for-ido smex-cache))) (defun smex-convert-for-ido (command-items) - (mapcar (lambda (command-item) (symbol-name (car command-item))) command-items)) + (delq nil (mapcar #'(lambda (command-item) + (let ((command-sym (car command-item)) + (command-str (symbol-name (car command-item)))) + (if (and command-sym + (or (get command-sym 'smex-ignore) ; request to be ignored + (get command-sym 'byte-obsolete-info) ; marked obsolete + (string-match-p "\\`ad-Orig-" command-str) ; there is also an advised form with true name + (string-match-p "\\`menu-bar-" command-str) ; menu-bar are likely duplicates + (and (listp (help-function-arglist command-sym)) ; mouse-interactive, roughly + (not (eq ?\& (aref (symbol-name (car (help-function-arglist command-sym))) 0))) + (stringp (cadr (interactive-form command-sym))) + (string-match-p "\\`[*@^]*e" (cadr (interactive-form command-sym)))))) + nil + ;; else + command-str))) + command-items))) + +(defun smex-ignore (commands) + "Tell smex to ignore the list of symbols in COMMANDS. + +Ignored commands are still usable, but are hidden from completion +in smex. + +If COMMANDS is a single symbol, it will be coerced to a list." + (when (symbolp commands) + (setq commands (list commands))) + (dolist (sym commands) + (put sym 'smex-ignore t))) (defun smex-restore-history () "Rearranges `smex-cache' according to `smex-history'"