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

@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