Skip to content

Instantly share code, notes, and snippets.

@maavelar5
Created November 1, 2020 04:35
Show Gist options
  • Save maavelar5/81b22d52a47e125e62a04c39ef7e08cd to your computer and use it in GitHub Desktop.
Save maavelar5/81b22d52a47e125e62a04c39ef7e08cd to your computer and use it in GitHub Desktop.
emacs + dmenu
(setq dmenu-cfg " | dmenu -i -l 20 -p .")
(defun dmenu-ag ()
(interactive)
(setq my_shell_output (shell-command-to-string (concat "ag . " dmenu-cfg)))
(setq splitted (split-string my_shell_output ":"))
(when (> (length splitted) 1)
(find-file (car splitted))
(goto-line (string-to-number (nth 1 splitted)))))
(defun dmenu-ag-in-file ()
(interactive)
(setq my_command (concat "ag . " buffer-file-name dmenu-cfg))
(setq my_shell_output (shell-command-to-string my_command))
(setq splitted (split-string my_shell_output ":"))
(when (> (length splitted) 1)
(goto-line (string-to-number (car splitted)))))
(defun dmenu-find-file (&optional dir)
(interactive)
(setq command (concat "ls -a" dmenu-cfg))
(setq output (shell-command-to-string command))
(when (> (length output) 1)
(find-file (substring output 0 -1))))
(defun dmenu-switch-buffer (&optional dir)
(interactive)
(setq command (concat (format "%s" (buffer-list)) dmenu-cfg))
(setq splitted (split-string my_shell_output ":"))
(print command))
@Naheel-Azawy
Copy link

Hi, I wanted to write something kinda similar to this for a while but I'm not good at elisp and never had enough time to learn it properly. My idea was to turn dmenu into a helm replacement. From your experience, how hard/easy would that be?

@maavelar5
Copy link
Author

maavelar5 commented Jan 26, 2021

Hi, I wanted to write something kinda similar to this for a while but I'm not good at elisp and never had enough time to learn it properly. My idea was to turn dmenu into a helm replacement. From your experience, how hard/easy would that be?

Hello, I'm not that good with elisp either, I can write small snippets like this but as far as best practices for large packages I'm not good. Helm is quite large from what I can tell so it depends on how much of its functionality you'd like to implement, there's also the problem that because Dmenu operates outside of emacs, many things would need to be added to the source (syntax highlighting off the top of my head). All in all, I'd say that it will require quite a bit of work. Hope it helps. Cheers

@Naheel-Azawy
Copy link

@maavelar5 I guess this means I'll leave it far in the wish list. But still, thanks for your cool snippets here and have a nice day!

@pataquets
Copy link

Dropping the YouTube video, for the record:
(1062) Emacs + dmenu is awesome! bye bye Ivy! - YouTube

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment