From 00ad6e50fd2ce58e364cd83b37b15deadda62caf Mon Sep 17 00:00:00 2001 From: Emanuele Tomasi Date: Fri, 24 Nov 2017 20:01:32 +0100 Subject: [PATCH 1/2] Hiding commands smex-filter-alist: a list of regexes for hiding commands! --- README.markdown | 3 +++ smex.el | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 6dbb6aa..f17618c 100644 --- a/README.markdown +++ b/README.markdown @@ -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 +Set `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. diff --git a/smex.el b/smex.el index 6d4a72b..a66fdb5 100644 --- a/smex.el +++ b/smex.el @@ -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'. @@ -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)) From 50136b939cd12ea7d4d076c13f48ba492bd5951d Mon Sep 17 00:00:00 2001 From: Emanuele Tomasi Date: Fri, 24 Nov 2017 20:28:39 +0100 Subject: [PATCH 2/2] Typo --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index f17618c..d2ff60f 100644 --- a/README.markdown +++ b/README.markdown @@ -71,7 +71,7 @@ been idle for 60 seconds: Call `(smex-auto-update)`; provide an integer argument for a custom time period in seconds. ### Hiding commands -Set `smex-filter-alist` is a list of regexes that you can use for 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