diff --git a/.emacs.d/init.el b/.emacs.d/init.el index f7b15637..be0286bf 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -113,11 +113,9 @@ (when (require 'evil nil t) (require 'init-evil)) (with-eval-after-load 'eshell (require 'init-eshell)) -(autoload 'helm-eshell-switch "eshell") (with-eval-after-load 'shell (require 'init-shell)) (with-eval-after-load 'eww (require 'init-eww)) -(autoload 'helm-eww-switch "eww") (when (require 'expand-region nil t) (global-set-key (kbd "C-=") 'er/expand-region)) @@ -174,15 +172,8 @@ (when (require 'info-colors nil t) (add-hook 'Info-selection-hook 'info-colors-fontify-node)) -(with-eval-after-load 'helm - (helm-defswitcher - "Info" - (lambda (b) - (with-current-buffer b - (derived-mode-p 'Info-mode))) - (lambda (&optional candidate) - (info nil (when candidate (format "*info*<%s>" candidate))))) - (global-set-key (kbd "C-h i") 'helm-info-switch)) +(when (require 'helm-selector nil :noerror) + (global-set-key (kbd "C-h i") 'helm-selector-info)) (add-hook 'js-mode-hook (lambda () (defvaralias 'js-indent-level 'tab-width))) @@ -190,6 +181,7 @@ (with-eval-after-load 'scheme (require 'init-scheme)) (with-eval-after-load 'racket-mode (require 'init-racket)) (with-eval-after-load 'clojure-mode (require 'init-clojure)) + (setq geiser-repl-history-filename (expand-file-name "geiser_history" user-emacs-directory)) ;; Emacs Lisp (add-hook 'emacs-lisp-mode-hook 'ambrevar/turn-on-complete-filename) @@ -248,7 +240,6 @@ ;; (autoload 'helm-mu4e-switch "mu4e") (with-eval-after-load 'notmuch (require 'init-notmuch)) -(autoload 'helm-notmuch-switch "notmuch") (with-eval-after-load 'make-mode (require 'init-makefile)) @@ -268,10 +259,8 @@ (with-eval-after-load 'mediawiki (require 'init-mediawiki)) (with-eval-after-load 'elfeed (require 'init-elfeed)) -(autoload 'helm-elfeed-switch "elfeed") (with-eval-after-load 'org (require 'init-org)) -(autoload 'helm-org-switch "org") ;;; pdf-tools requires poppler built with cairo support. ;;; We cannot defer loading as `pdf-tools-install' is required for PDF diff --git a/.emacs.d/lisp/init-elfeed.el b/.emacs.d/lisp/init-elfeed.el index ef8eec3b..d885dfb0 100644 --- a/.emacs.d/lisp/init-elfeed.el +++ b/.emacs.d/lisp/init-elfeed.el @@ -87,16 +87,6 @@ visit otherwise." (funcall elfeed-show-entry-switch buff))) (advice-add 'elfeed-show-entry :override 'ambrevar/elfeed-show-entry) -(when (require 'patch-helm nil 'noerror) - (helm-defswitcher - "elfeed" - (lambda (b) - (with-current-buffer b - (or - (derived-mode-p 'elfeed-search-mode) - (derived-mode-p 'elfeed-show-mode)))) - elfeed)) - (defun ambrevar/elfeed-setup () (add-hook 'window-configuration-change-hook 'elfeed-search-update--force nil t)) ;; This is too slow on big buffers. diff --git a/.emacs.d/lisp/init-eshell.el b/.emacs.d/lisp/init-eshell.el index 70dd419f..1aa5e72d 100644 --- a/.emacs.d/lisp/init-eshell.el +++ b/.emacs.d/lisp/init-eshell.el @@ -214,34 +214,6 @@ This should be faster then `seq-uniq'." ;; (setq epa-file-encrypt-to "mail@ambrevar.xyz")) ;; (add-hook 'eshell-mode-hook 'ambrevar/fix-local-epa-file-encrypt-to) -;;; Spawning -(require 'init-shell); For `helm-ff-preferred-shell-mode'. -(when (require 'patch-helm nil 'noerror) - (helm-defswitcher - "Eshell" - (lambda (b) - (with-current-buffer b - (or - (derived-mode-p 'eshell-mode) - (derived-mode-p 'shell-mode)))) - (lambda (&optional name) - (if (eq helm-ff-preferred-shell-mode 'eshell-mode) - (eshell 'new) - (shell (generate-new-buffer (generate-new-buffer-name "*shell*")))) - (when name - (rename-buffer (format "*%sshell<%s>*" - (if (eq helm-ff-preferred-shell-mode 'eshell-mode) "e" "") - name) - 'unique))) - nil - (helm-build-dummy-source - "Create shell buffer" - :action `(("Create shell buffer" . - (lambda (candidate) - (let ((new-buffer (save-window-excursion (shell (format "*shell<%s>*" candidate)) - (current-buffer)))) - (switch-to-buffer new-buffer)))))))) - ;;; Auto-suggestion (when (require 'esh-autosuggest nil t) (setq esh-autosuggest-delay 0.75) diff --git a/.emacs.d/lisp/init-eww.el b/.emacs.d/lisp/init-eww.el index 19593e4c..59c494e2 100644 --- a/.emacs.d/lisp/init-eww.el +++ b/.emacs.d/lisp/init-eww.el @@ -68,20 +68,6 @@ If BUFFERS is not specified, then reload all buffers." (when (derived-mode-p 'eww-mode) (eww-reload))))) -(when (require 'patch-helm nil 'noerror) - (helm-defswitcher - "eww" - (lambda (b) - (with-current-buffer b - (derived-mode-p 'eww-mode))) - (lambda (&optional _) - (interactive) - (if (thing-at-point-url-at-point) - ;; This only works fine if no EWW buffer is up. - (call-interactively 'eww) - (helm-eww))) - helm-eww)) - (defun ambrevar/eww (url) "Fetch URL and render the page. If the input doesn't look like an URL or a domain name, the diff --git a/.emacs.d/lisp/init-exwm.el b/.emacs.d/lisp/init-exwm.el index e457ba84..733f507e 100644 --- a/.emacs.d/lisp/init-exwm.el +++ b/.emacs.d/lisp/init-exwm.el @@ -77,14 +77,26 @@ (exwm-input-set-key (kbd "C-6") #'evil-switch-to-windows-last-buffer)) ;;; Emacs mode shortcuts. -(if (not (fboundp 'helm-org-switch)) - (exwm-input-set-key (kbd "s-t") (lambda () (interactive) (find-file (car org-agenda-files)))) - (exwm-input-set-key (kbd "s-t") #'helm-org-switch) - (exwm-input-set-key (kbd "s-T") #'helm-org-switch-other-window)) -(if (not (fboundp 'helm-eshell-switch)) - (exwm-input-set-key (kbd "s-") #'eshell) - (exwm-input-set-key (kbd "s-") #'helm-eshell-switch) - (exwm-input-set-key (kbd "S-s-") #'helm-eshell-switch-other-window)) +(if (not (require 'helm-selector nil :noerror)) + (progn + (exwm-input-set-key (kbd "s-t") (lambda () + (interactive) + (find-file (car org-agenda-files)))) + (exwm-input-set-key (kbd "s-") #'eshell) + (exwm-input-set-key (kbd "s-m") #'notmuch-hello) + (exwm-input-set-key (kbd "s-n") #'elfeed) + (exwm-input-set-key (kbd "s-e") #'eww)) + (exwm-input-set-key (kbd "s-t") 'helm-selector-org) + (exwm-input-set-key (kbd "s-T") 'helm-selector-org-other-window) + (exwm-input-set-key (kbd "s-") 'helm-selector-shell) + (exwm-input-set-key (kbd "S-s-") 'helm-selector-shell-other-window) + (exwm-input-set-key (kbd "s-m") #'helm-selector-notmuch) + (exwm-input-set-key (kbd "s-M") #'helm-selector-notmuch-other-window) + (exwm-input-set-key (kbd "s-n") #'helm-selector-elfeed) + (exwm-input-set-key (kbd "s-N") #'helm-selector-elfeed-other-window) ; "n" for "news" + (exwm-input-set-key (kbd "s-e") #'helm-selector-eww) + (exwm-input-set-key (kbd "s-E") #'helm-selector-eww-other-window)) + (when (fboundp 'magit-status) (exwm-input-set-key (kbd "s-v") #'magit-status)) (when (fboundp 'emms-all) @@ -93,24 +105,6 @@ (if (fboundp 'helm-emms) (exwm-input-set-key (kbd "s-A") #'helm-emms) (exwm-input-set-key (kbd "s-A") #'emms))) -;; (when (or (fboundp 'mu4e) -;; (delq nil (mapcar (lambda (path) (string-match "/mu4e/\\|/mu4e$" path)) load-path))) -;; (if (not (fboundp 'helm-mu4e-switch)) -;; (exwm-input-set-key (kbd "s-m") #'ambrevar/mu4e-headers) -;; (exwm-input-set-key (kbd "s-m") #'helm-mu4e-switch) -;; (exwm-input-set-key (kbd "s-M") #'helm-mu4e-switch-other-window))) -(if (not (fboundp 'helm-notmuch-switch)) - (exwm-input-set-key (kbd "s-m") #'notmuch-hello) - (exwm-input-set-key (kbd "s-m") #'helm-notmuch-switch) - (exwm-input-set-key (kbd "s-M") #'helm-notmuch-switch-other-window)) -(if (not (fboundp 'helm-elfeed-switch)) - (exwm-input-set-key (kbd "s-n") #'elfeed) - (exwm-input-set-key (kbd "s-n") #'helm-elfeed-switch) - (exwm-input-set-key (kbd "s-N") #'helm-elfeed-switch-other-window)) ; "n" for "news" -(if (not (fboundp 'helm-eww-switch)) - (exwm-input-set-key (kbd "s-e") #'eww) - (exwm-input-set-key (kbd "s-e") #'helm-eww-switch) - (exwm-input-set-key (kbd "s-E") #'helm-eww-switch-other-window)) (when (fboundp 'helm-pass) (exwm-input-set-key (kbd "s-p") #'helm-pass)) @@ -120,22 +114,25 @@ (defun ambrevar/repl-switcher () "Switch between Geiser and SLIME REPLs." (interactive) + ;; TODO: Apparently, S-s- is not recognized. (pcase (completing-read "Lisp: " '(cider geiser slime sly racket)) ("cider" - (exwm-input-set-key (kbd "s-") #'ambrevar/cider-switch-to-repl)) + (exwm-input-set-key (kbd "s-") 'helm-selector-cider) + (exwm-input-set-key (kbd "M-s-") 'helm-selector-cider-other-window)) ("geiser" (autoload 'helm-geiser-repl-switch "init-scheme") - (exwm-input-set-key (kbd "s-") #'helm-geiser-repl-switch) - (exwm-input-set-key (kbd "S-s-") #'helm-geiser-repl-switch-other-window)) + (exwm-input-set-key (kbd "s-") 'helm-selector-geiser) + (exwm-input-set-key (kbd "M-s-") 'helm-selector-geiser-other-window)) ("slime" - (exwm-input-set-key (kbd "s-") #'ambrevar/slime-switch-to-repl)) + (exwm-input-set-key (kbd "s-") 'helm-selector-slime) + (exwm-input-set-key (kbd "M-s-") 'helm-selector-slime-other-window)) ("sly" - (exwm-input-set-key (kbd "s-") #'ambrevar/sly-switch-to-repl)) + (exwm-input-set-key (kbd "s-") 'helm-selector-sly) + (exwm-input-set-key (kbd "") 'helm-selector-sly-other-window)) ("racket" (exwm-input-set-key (kbd "s-") #'racket-repl)))) (exwm-input-set-key (kbd "s-C-") #'ambrevar/repl-switcher) -(autoload #'ambrevar/cider-switch-to-repl "init-clojure") ;;; External application shortcuts. (defun ambrevar/exwm-start (command) diff --git a/.emacs.d/lisp/init-mu4e.el b/.emacs.d/lisp/init-mu4e.el index 7d8a42ec..0bff84f3 100644 --- a/.emacs.d/lisp/init-mu4e.el +++ b/.emacs.d/lisp/init-mu4e.el @@ -121,20 +121,6 @@ If MSG is nil, use message at point." (interactive) (kill-new (mu4e-message-field (or msg (mu4e-message-at-point)) :message-id))) -(when (require 'patch-helm nil 'noerror) - (helm-defswitcher - "mu4e" - (lambda (b) - (with-current-buffer b - (or - (derived-mode-p 'mu4e-main-mode) - (derived-mode-p 'mu4e-headers-mode) - (derived-mode-p 'mu4e-view-mode) - (derived-mode-p 'mu4e-compose-mode) - (when (require 'mu4e-conversation nil 'noerror) - (mu4e-conversation--buffer-p b))))) - ambrevar/mu4e-headers)) - (load "~/personal/mail/mu4e.el" t) (provide 'init-mu4e) diff --git a/.emacs.d/lisp/init-notmuch.el b/.emacs.d/lisp/init-notmuch.el index cde5d76e..b0da8e21 100644 --- a/.emacs.d/lisp/init-notmuch.el +++ b/.emacs.d/lisp/init-notmuch.el @@ -30,12 +30,6 @@ (message-remove-header "Fcc") (notmuch-fcc-header-setup)) -(when (require 'patch-helm nil 'noerror) - (helm-defswitcher - "notmuch" - #'notmuch-interesting-buffer - notmuch-hello)) - (when (require 'helm-notmuch nil t) (setq helm-notmuch-match-incomplete-words t) (dolist (map (list notmuch-search-mode-map diff --git a/.emacs.d/lisp/init-org.el b/.emacs.d/lisp/init-org.el index d8c8272d..6f5c51a7 100644 --- a/.emacs.d/lisp/init-org.el +++ b/.emacs.d/lisp/init-org.el @@ -30,18 +30,6 @@ (add-to-list 'org-agenda-files "~/personal/todo/todo.org.gpg") (load "~/personal/todo/agenda-list.el" 'noerror) -(when (require 'patch-helm nil 'noerror) - (helm-defswitcher - "Org" - (lambda (b) - (when (buffer-file-name b) - (member (file-truename (buffer-file-name b)) (mapcar #'file-truename org-agenda-files)))) - (lambda () (find-file (car org-agenda-files))) - nil - (helm-make-source "Org agenda files" 'helm-source-ffiles - ;; Unclear why, but if we don't copy the list, the last element gets removed. - :candidates (lambda () (copy-list org-agenda-files))))) - ;;; Set PDF association in Org-mode (original is 'default). (setcdr (assoc "\\.pdf\\'" org-file-apps) 'emacs) diff --git a/.emacs.d/lisp/init-scheme.el b/.emacs.d/lisp/init-scheme.el index 4d096af8..779d16c1 100644 --- a/.emacs.d/lisp/init-scheme.el +++ b/.emacs.d/lisp/init-scheme.el @@ -18,19 +18,6 @@ (add-hook 'scheme-mode-hook 'al/scheme-fix-docstring-font-lock))) (when (require 'geiser-impl nil 'noerror) - (helm-defswitcher - "Geiser-REPL" - (lambda (b) - (with-current-buffer b - (derived-mode-p 'geiser-repl-mode))) - (lambda (&optional candidate) - (defun ambrevar/geiser-repl-buffer-name (impl) - (format "* %s%s *" (geiser-repl--repl-name impl) - (if candidate (format "-%s" candidate) ""))) - (advice-add 'geiser-repl-buffer-name :override 'ambrevar/geiser-repl-buffer-name) - (call-interactively 'run-geiser) - (advice-remove 'geiser-repl-buffer-name 'ambrevar/geiser-repl-buffer-name))) - ;; (setq geiser-repl-skip-version-check-p t ;; geiser-mode-start-repl-p t) (setq geiser-active-implementations (delq 'chicken geiser-active-implementations) diff --git a/.emacs.d/lisp/patch-helm.el b/.emacs.d/lisp/patch-helm.el deleted file mode 100644 index de738376..00000000 --- a/.emacs.d/lisp/patch-helm.el +++ /dev/null @@ -1,78 +0,0 @@ -;; TODO: Since Helm 3.1, we can pop up buffers in other window/frame. -(defun ambrevar/helm-source-buffer-not-found (&optional mode new-fn) - "See `helm-source-buffer-not-found'." - (helm-build-dummy-source - "Create buffer" - :action `(("Create buffer (C-u choose mode)" . - (lambda (candidate) - (if (not ,new-fn) - (let ((mjm (or (and helm-current-prefix-arg - (intern-soft (helm-comp-read - "Major-mode: " - helm-buffers-favorite-modes))) - ,mode - (cl-loop for (r . m) in auto-mode-alist - when (string-match r candidate) - return m))) - (buffer (get-buffer-create candidate))) - (if mjm - (with-current-buffer buffer (funcall mjm)) - (set-buffer-major-mode buffer)) - (switch-to-buffer buffer)) - (let ((new-buffer (save-window-excursion (funcall ',new-fn candidate) - (current-buffer)))) - (switch-to-buffer new-buffer)))))))) - -(defmacro helm-deflister (name predicate new-fn &optional extra-sources) - (let ((buffer-source-name (format "%s buffers" name))) - (add-to-list 'helm-source-names-using-follow buffer-source-name) - `(defun ,(intern (format "helm-%s-buffers" (downcase name))) () - (interactive) - (helm - :sources - (list (helm-make-source ,(format "%s buffers" name) 'helm-source-buffers - :buffer-list (lambda () - (cl-loop for b in (buffer-list) - when (funcall ,predicate b) - collect (buffer-name b)))) - ,@(let ((mode (intern (format "%s-mode" (downcase name))))) - (unless (fboundp mode) - ;; For cased mode names like `Info-mode'. - (setq mode (intern (format "%s-mode" name)))) - (when (fboundp mode) - `((ambrevar/helm-source-buffer-not-found - ',mode - ,new-fn)))) - ,@extra-sources) - :buffer ,(format "*helm-%s-buffers*" name))))) - -(defmacro helm-defswitcher (name predicate new-fn &optional helm-lister &rest extra-sources) - "Create an interactive buffer switcher for NAME. -When current buffer is not of NAME, switch to last NAME session if any. -Otherwise create a new one and switch to it. -If current buffer is of NAME, show the buffer list." - (let ((switch (intern (format "helm-%s-switch" (downcase name))))) - `(progn - (helm-deflister ,name ,predicate ,new-fn ,extra-sources) - (defun ,switch (&optional menu other-window) - (interactive "P") - (if (or menu (funcall ,predicate (current-buffer))) - ;; TODO: Funcall the return value of helm-deflister. - (funcall ',(or helm-lister - (intern (format "helm-%s-buffers" (downcase name))))) - (let ((last (cl-loop for buffer in (buffer-list) - when (funcall ,predicate buffer) - return buffer))) - (if last - (if (get-buffer-window last) - (select-window (get-buffer-window last)) - (funcall (if other-window 'switch-to-buffer-other-window 'switch-to-buffer) last)) - ;; First buffer: - (let ((first-buffer (save-window-excursion (funcall #',new-fn) (current-buffer)))) - (funcall (if other-window 'switch-to-buffer-other-window 'switch-to-buffer) - first-buffer)))))) - (defun ,(intern (format "helm-%s-switch-other-window" (downcase name))) (&optional menu) - (interactive "P") - (funcall ',switch menu 'other-window))))) - -(provide 'patch-helm)