SiteMap Search ElispArea HowTo Glossary RecentChanges News Problems Suggestions
Yemen, National Day

CommandSubset

About Lisp:jcl-command-subset.el.

For user-defined commands the convention is to prefix them with a more or less unique string. For example i choose to prefix my commands with jcl-. To call such a command with M-x i always have to type M-x jcl- first. Instead i type M-z. That will behave just like M-x but jcl- is already typed. The default binding for this keystroke zap-to-char i find more annoying than useful.

I find this helpful especially for commands that are not used very often. If binding such a command to a keystroke it is hard to remember it. A command name is often easier to remember.

It can be used like this:

;; Define a subset with all commands that starts with "jcl-".
(jcl-define-command-subset jcl-command-subset "M-z " "^jcl-" "jcl-")  

;; Define a subset with all commands which have the string "toggle"
;; in their name.
(jcl-define-command-subset jcl-toggle-command-subset "M-Z " "toggle")

;; Define a subset with all monkey related commands.
(jcl-define-command-subset jcl-monkey-command-subset
                              "Select monkey business: "
                              "monkey\\|ape\\|chimp\\|gorilla")


(define-key global-map [(meta ?z)] 'jcl-command-subset)
(define-key global-map [(meta ?Z)] 'jcl-toggle-command-subset)
(defalias 'monkey 'jcl-monkey-command-subset)

(jcl-command-subset-setup)

Each subset have a list with all commands in it. One way to update the list is to repeat the command. In the example above this would be done by hitting M-z M-z.


CategoryCommands