Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Filter out unwanted commands from smex completions #20

Open
wants to merge 2 commits into from

1 participant

@rolandwalker

The mouse-interactive filtering is crude; it may miss some commands but there are no false positives.
Adds a function for marking commands as unwanted.

rolandwalker added some commits
@rolandwalker rolandwalker set this-command along with current-prefix-arg 6a4c512
@rolandwalker rolandwalker 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.
f21e593
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 20, 2012
  1. @rolandwalker
Commits on Aug 21, 2012
  1. @rolandwalker

    Filter unwanted commands from the smex prompt

    rolandwalker authored
    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.
This page is out of date. Refresh to see the latest.
Showing with 29 additions and 1 deletion.
  1. +29 −1 smex.el
View
30 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)
@@ -173,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'"
Something went wrong with that request. Please try again.