reddit / emacs

A small transient menu for customize

kjiehs · 2022-03-03 23:39
This adds a small menu which lets you call useful customize options and also manipulate file and directory local variables. ​ [Entry point to custom.el functionality](https://preview.redd.it/pgzjlptd89l81.png?width=520&format=png&auto=webp&s=ba309497b8e3f64f00b1b79bd9a802d58ea0e58e) ​ [Menu to add\/delete\/change file and directory local variables and property line](https://preview.redd.it/0ku1fx7g89l81.png?width=648&format=png&auto=webp&s=151453073cae1a60b39df6d33cb41d23f43f565b) This is from my personal config. I thought it might be useful for others as well but too simple to be it's own package. Here is the code: (transient-define-prefix shk-customize-locals-menu () "A menu to manipulate file/dir local variables" ["Local variables" ["File" ("fa" "add" add-file-local-variable) ("fd" "delete" delete-file-local-variable) ("*a" "add prop" add-file-local-variable-prop-line) ("*d" "delete prop" delete-file-local-variable-prop-line)] ["Dir" ("da" "add" add-dir-local-variable) ("dd" "delete" delete-dir-local-variable)] ["Move" ("df" "dir → file" copy-dir-locals-to-file-locals) ("d*" "dir → prop" copy-dir-locals-to-file-locals-prop-line) ("fd" "file → dir" copy-file-locals-to-dir-locals)]]) (transient-define-prefix shk-customize-menu () "A menu to open customize options" [["Custom" ("," "List groups" customize) ("/" "Search" customize-apropos) ("r" "Rogue" customize-rogue) ("s" "Saved" customize-saved) ("S" "Unsaved" customize-unsaved)] ["Settings" ("o" "Option" customize-option) ("g" "Group" customize-group) ("f" "Face" customize-face) ("l" "Local variables" shk-customize-locals-menu)]]) (global-set-key (kbd "A-,") 'shk-customize-menu) (global-set-key (kbd "C-c ,") 'shk-customize-menu)
curioushom · 2022-03-04 04:54
Thanks for posting! I didn't realize it was this straight forward to create your own transient menus. These kinds of examples are super useful for less experienced users like myself. Thanks again!
xircon · 2022-03-04 08:45
``` (global-set-key (kbd "A-,") 'shk-customize-menu) ``` What modifier is A? M, s, S, C I get :D
kjiehs · 2022-03-04 16:03
Oh, sorry. Should have thought of that. It's Mac's command key after the following remapping: ``` (setq mac-command-modifier 'alt) (setq mac-option-modifier 'meta) ```
hmelman · 2022-03-04 23:36
Nice. I have a similar one that might be of interest. I also have a mac and have the command key be super and it feels very mac-like getting to this transient via `command-,`. I mostly just use `s-, g` to customize a group, but that makes this a perfect transient, as I get help when I want to use another command whose binding I don't remember. ;;; customize things via OSX standard keybinding cmd-, (transient-define-prefix hrm-customize-transient () "Customize Emacs settings" ["Customize Emacs settings" ["Global" ("C" "Customize" customize) ("B" "Browse" customize-browse) ("A" "Apropos" customize-apropos) ] ["Basic" ("g" "Group" customize-group) ("o" "Option" customize-option) ("v" "Option" customize-option) ("f" "Face" customize-face) ] ["Other Window" ("4g" "Group" customize-group-other-window) ("4o" "Option" customize-option-other-window) ("4v" "Option" customize-option-other-window) ("4f" "Face" customize-face-other-window) ] ] ["Advanced" ["Apropos" ("aa" "Everything" customize-apropos) ("ag" "Groups" customize-apropos-groups) ("ao" "Options" customize-apropos-options) ("af" "Faces" customize-apropos-faces) ] ["Search" ("n" "Since Version" customize-changed-options) ("u" "Unsaved" customize-unsaved) ("s" "Saved" customize-saved) ("r" "Rogue" customize-rogue) ; set outside custom ] ["Themes" ("t" "Theme" customize-themes) ("T" "Create Theme" customize-create-theme) ] ] ) (global-set-key (kbd "s-,") 'hrm-customize-transient)