Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hiding commands #72

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ Additionally, you can teach Smex to auto-update after Emacs has
been idle for 60 seconds: Call `(smex-auto-update)`; provide an integer
argument for a custom time period in seconds.

### Hiding commands
`smex-filter-alist` is a list of regexes that you can use for hiding commands.

### Show unbound commands
`smex-show-unbound-commands` shows frequently used commands that have
no key bindings.
Expand Down
18 changes: 17 additions & 1 deletion smex.el
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ Turn it off for minor speed improvements on older systems."
:type 'boolean
:group 'smex)

(defcustom smex-filter-alist nil
"List used by `Smex' to hide command names. Every command name that matches
one of these regexes will be hide."
:type '(repeat regexp)
:initialize 'custom-initialize-default
:set (lambda (symbol value)
(when (fboundp 'smex-cache)
(set-default symbol value)
(smex-update)))
:group 'smex)

(defcustom smex-save-file (locate-user-emacs-file "smex-items" ".smex-items")
"File in which the smex state is saved between Emacs sessions.
Variables stored are: `smex-data', `smex-history'.
Expand Down Expand Up @@ -180,7 +191,12 @@ Set this to nil to disable fuzzy matching."

(setq smex-cache (sort smex-cache 'smex-sorting-rules))
(smex-restore-history)
(setq smex-ido-cache (smex-convert-for-ido smex-cache)))
(setq smex-ido-cache (smex-filter-commands
(smex-convert-for-ido smex-cache))))

(defun smex-filter-commands (commands)
(dolist (filter smex-filter-alist commands)
(cl-delete-if (lambda (item) (string-match filter item)) commands)))

(defun smex-convert-for-ido (command-items)
(mapcar (lambda (command-item) (symbol-name (car command-item))) command-items))
Expand Down