Conform many modules to new conventions

This commit is contained in:
Henrik Lissner 2019-07-23 12:30:47 +02:00
parent 20e2aa0b18
commit c795a988e6
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
26 changed files with 161 additions and 165 deletions

View file

@ -381,11 +381,11 @@ successfully sets indent_style/indent_size.")
`(("." . ,(concat doom-cache-dir "undo-tree-hist/")))) `(("." . ,(concat doom-cache-dir "undo-tree-hist/"))))
(when (executable-find "zstd") (when (executable-find "zstd")
(def-advice! doom--undo-tree-make-history-save-file-name-a (file) (def-advice! doom-undo-tree-make-history-save-file-name-a (file)
:filter-return #'undo-tree-make-history-save-file-name :filter-return #'undo-tree-make-history-save-file-name
(concat file ".zst"))) (concat file ".zst")))
(def-advice! doom--undo-tree-strip-text-properties-a (&rest _) (def-advice! doom-undo-tree-strip-text-properties-a (&rest _)
:before #'undo-list-transfer-to-tree :before #'undo-list-transfer-to-tree
(dolist (item buffer-undo-list) (dolist (item buffer-undo-list)
(and (consp item) (and (consp item)

View file

@ -385,10 +385,10 @@ treat Emacs as a non-application window."
(defvar doom--ediff-saved-wconf nil) (defvar doom--ediff-saved-wconf nil)
;; Restore window config after quitting ediff ;; Restore window config after quitting ediff
(add-hook 'ediff-before-setup-hook (add-hook 'ediff-before-setup-hook
(defun doom--ediff-save-wconf-h () (defun doom-ediff-save-wconf-h ()
(setq doom--ediff-saved-wconf (current-window-configuration)))) (setq doom--ediff-saved-wconf (current-window-configuration))))
(add-hook! '(ediff-quit-hook ediff-suspend-hook) (add-hook! '(ediff-quit-hook ediff-suspend-hook)
(defun doom--ediff-restore-wconf-h () (defun doom-ediff-restore-wconf-h ()
(when (window-configuration-p doom--ediff-saved-wconf) (when (window-configuration-p doom--ediff-saved-wconf)
(set-window-configuration doom--ediff-saved-wconf))) (set-window-configuration doom--ediff-saved-wconf)))
'append)) 'append))

View file

@ -361,9 +361,9 @@ intervals."
(nconc doom-incremental-packages packages) (nconc doom-incremental-packages packages)
(when packages (when packages
(let ((gc-cons-threshold most-positive-fixnum) (let ((gc-cons-threshold most-positive-fixnum)
(reqs (cl-delete-if #'featurep packages)) (file-name-handler-alist nil)
file-name-handler-alist) (reqs (cl-delete-if #'featurep packages)))
(when-let (req (if reqs (ignore-errors (pop reqs)))) (when-let (req (if reqs (pop reqs)))
(doom-log "Incrementally loading %s" req) (doom-log "Incrementally loading %s" req)
(condition-case e (condition-case e
(or (while-no-input (require req nil t) t) (or (while-no-input (require req nil t) t)

View file

@ -46,7 +46,7 @@
))) )))
;;;###autoload ;;;###autoload
(defun +calendar*cfw:render-button (title command &optional state) (defun +calendar-cfw:render-button-a (title command &optional state)
"render-button "render-button
TITLE TITLE
COMMAND COMMAND

View file

@ -8,7 +8,7 @@
;; Packages ;; Packages
(def-package! calfw (def-package! calfw
:commands (cfw:open-calendar-buffer) :commands cfw:open-calendar-buffer
:config :config
;; better frame for calendar ;; better frame for calendar
(setq cfw:face-item-separator-color nil (setq cfw:face-item-separator-color nil
@ -27,7 +27,7 @@
(add-hook 'cfw:calendar-mode-hook #'doom-mark-buffer-as-real-h) (add-hook 'cfw:calendar-mode-hook #'doom-mark-buffer-as-real-h)
(add-hook 'cfw:calendar-mode-hook 'hide-mode-line-mode) (add-hook 'cfw:calendar-mode-hook 'hide-mode-line-mode)
(advice-add #'cfw:render-button :override #'+calendar*cfw:render-button)) (advice-add #'cfw:render-button :override #'+calendar-cfw:render-button-a))
(def-package! calfw-org (def-package! calfw-org

View file

@ -47,7 +47,7 @@ playback.")
;; Packages ;; Packages
(def-package! circe (def-package! circe
:commands (circe circe-server-buffers) :commands circe circe-server-buffers
:init (setq circe-network-defaults nil) :init (setq circe-network-defaults nil)
:config :config
(setq circe-default-quit-message nil (setq circe-default-quit-message nil
@ -92,11 +92,12 @@ playback.")
(add-hook 'circe-channel-mode-hook #'turn-on-visual-line-mode) (add-hook 'circe-channel-mode-hook #'turn-on-visual-line-mode)
(defun +irc*circe-disconnect-hook (&rest _) (def-advice! +irc-circe-disconnect-hook-a (&rest _)
:after #'circe--irc-conn-disconnected
(run-hooks '+irc-disconnect-hook)) (run-hooks '+irc-disconnect-hook))
(advice-add 'circe--irc-conn-disconnected :after #'+irc*circe-disconnect-hook)
(defun +irc*circe-truncate-nicks () (add-hook 'lui-pre-output-hook
(defun +irc-circe-truncate-nicks-h ()
"Truncate long nicknames in chat output non-destructively." "Truncate long nicknames in chat output non-destructively."
(when-let (beg (text-property-any (point-min) (point-max) 'lui-format-argument 'nick)) (when-let (beg (text-property-any (point-min) (point-max) 'lui-format-argument 'nick))
(goto-char beg) (goto-char beg)
@ -105,24 +106,24 @@ playback.")
:nick))) :nick)))
(when (> (length nick) +irc-left-padding) (when (> (length nick) +irc-left-padding)
(compose-region (+ beg +irc-left-padding -1) end (compose-region (+ beg +irc-left-padding -1) end
+irc-truncate-nick-char))))) +irc-truncate-nick-char))))))
(add-hook 'lui-pre-output-hook #'+irc*circe-truncate-nicks)
(add-hook 'doom-real-buffer-functions
(defun +circe-buffer-p (buf) (defun +circe-buffer-p (buf)
"Return non-nil if BUF is a `circe-mode' buffer." "Return non-nil if BUF is a `circe-mode' buffer."
(with-current-buffer buf (with-current-buffer buf
(and (derived-mode-p 'circe-mode) (and (derived-mode-p 'circe-mode)
(eq (safe-persp-name (get-current-persp)) (eq (safe-persp-name (get-current-persp))
+irc--workspace-name)))) +irc--workspace-name)))))
(add-hook 'doom-real-buffer-functions #'+circe-buffer-p)
(defun +irc|circe-message-option-bot (nick &rest ignored) (add-hook 'circe-message-option-functions
(defun +irc-circe-message-option-bot-h (nick &rest ignored)
"Fontify known bots and mark them to not be tracked." "Fontify known bots and mark them to not be tracked."
(when (member nick +irc-bot-list) (when (member nick +irc-bot-list)
'((text-properties . (face circe-fool-face lui-do-not-track t))))) '((text-properties . (face circe-fool-face lui-do-not-track t))))))
(add-hook 'circe-message-option-functions #'+irc|circe-message-option-bot)
(defun +irc|add-circe-buffer-to-persp () (add-hook 'circe-mode-hook
(defun +irc-add-circe-buffer-to-persp-h ()
(let ((persp (get-current-persp)) (let ((persp (get-current-persp))
(buf (current-buffer))) (buf (current-buffer)))
;; Add a new circe buffer to irc workspace when we're in another workspace ;; Add a new circe buffer to irc workspace when we're in another workspace
@ -130,8 +131,7 @@ playback.")
;; Add new circe buffers to the persp containing circe buffers ;; Add new circe buffers to the persp containing circe buffers
(persp-add-buffer buf (persp-get-by-name +irc--workspace-name)) (persp-add-buffer buf (persp-get-by-name +irc--workspace-name))
;; Remove new buffer from accidental workspace ;; Remove new buffer from accidental workspace
(persp-remove-buffer buf persp)))) (persp-remove-buffer buf persp)))))
(add-hook 'circe-mode-hook #'+irc|add-circe-buffer-to-persp)
;; Let `+irc/quit' and `circe' handle buffer cleanup ;; Let `+irc/quit' and `circe' handle buffer cleanup
(define-key circe-mode-map [remap kill-buffer] #'bury-buffer) (define-key circe-mode-map [remap kill-buffer] #'bury-buffer)
@ -194,20 +194,20 @@ playback.")
(setq lui-flyspell-p t)) (setq lui-flyspell-p t))
(after! evil (after! evil
(defun +irc|evil-insert () (defun +irc-evil-insert-h ()
"Ensure entering insert mode will put us at the prompt, unless editing "Ensure entering insert mode will put us at the prompt, unless editing
after prompt marker." after prompt marker."
(when (> (marker-position lui-input-marker) (point)) (when (> (marker-position lui-input-marker) (point))
(goto-char (point-max)))) (goto-char (point-max))))
(add-hook! 'lui-mode-hook (add-hook! 'lui-mode-hook
(add-hook 'evil-insert-state-entry-hook #'+irc|evil-insert nil t)) (add-hook 'evil-insert-state-entry-hook #'+irc-evil-insert-h nil t))
(mapc (lambda (cmd) (push cmd +irc-scroll-to-bottom-on-commands)) (mapc (lambda (cmd) (push cmd +irc-scroll-to-bottom-on-commands))
'(evil-paste-after evil-paste-before evil-open-above evil-open-below))) '(evil-paste-after evil-paste-before evil-open-above evil-open-below)))
(defun +irc|preinput-scroll-to-bottom () (defun +irc-preinput-scroll-to-bottom-h ()
"Go to the end of the buffer in all windows showing it. "Go to the end of the buffer in all windows showing it.
Courtesy of esh-mode.el" Courtesy of esh-mode.el"
(when (memq this-command +irc-scroll-to-bottom-on-commands) (when (memq this-command +irc-scroll-to-bottom-on-commands)
@ -224,22 +224,20 @@ Courtesy of esh-mode.el"
nil t))))) nil t)))))
(add-hook! 'lui-mode-hook (add-hook! 'lui-mode-hook
(add-hook 'pre-command-hook #'+irc|preinput-scroll-to-bottom nil t)) (add-hook 'pre-command-hook #'+irc-preinput-scroll-to-bottom-h nil t))
;; enable a horizontal line marking the last read message ;; enable a horizontal line marking the last read message
(add-hook! 'lui-mode-hook #'enable-lui-track-bar) (add-hook 'lui-mode-hook #'enable-lui-track-bar)
(defun +irc|init-lui-margins () (add-hook! 'lui-mode-hook
(defun +irc-init-lui-margins-h ()
(setq lui-time-stamp-position 'right-margin (setq lui-time-stamp-position 'right-margin
lui-time-stamp-format +irc-time-stamp-format lui-time-stamp-format +irc-time-stamp-format
right-margin-width (length (format-time-string lui-time-stamp-format)))) right-margin-width (length (format-time-string lui-time-stamp-format))))
(defun +irc-init-lui-wrapping-a ()
(defun +irc|init-lui-wrapping ()
(setq fringes-outside-margins t (setq fringes-outside-margins t
word-wrap t word-wrap t
wrap-prefix (make-string (+ +irc-left-padding 3) ? ))) wrap-prefix (make-string (+ +irc-left-padding 3) ? )))))
(add-hook! 'lui-mode-hook #'(+irc|init-lui-margins +irc|init-lui-wrapping)))
(def-package! lui-logging (def-package! lui-logging

View file

@ -46,7 +46,7 @@
;; Hooks ;; Hooks
;;;###autoload ;;;###autoload
(defun +rss|elfeed-wrap () (defun +rss-elfeed-wrap-h ()
"Enhances an elfeed entry's readability by wrapping it to a width of "Enhances an elfeed entry's readability by wrapping it to a width of
`fill-column'." `fill-column'."
(let ((inhibit-read-only t) (let ((inhibit-read-only t)
@ -57,7 +57,7 @@
(set-buffer-modified-p nil))) (set-buffer-modified-p nil)))
;;;###autoload ;;;###autoload
(defun +rss|cleanup () (defun +rss-cleanup-h ()
"Clean up after an elfeed session. Kills all elfeed and elfeed-org files." "Clean up after an elfeed session. Kills all elfeed and elfeed-org files."
(interactive) (interactive)
;; `delete-file-projectile-remove-from-cache' slows down `elfeed-db-compact' ;; `delete-file-projectile-remove-from-cache' slows down `elfeed-db-compact'
@ -75,7 +75,7 @@
(kill-buffer buf))) (kill-buffer buf)))
(dolist (b search-buffers) (dolist (b search-buffers)
(with-current-buffer b (with-current-buffer b
(remove-hook 'kill-buffer-hook #'+rss|cleanup :local) (remove-hook 'kill-buffer-hook #'+rss-cleanup-h :local)
(kill-buffer b))) (kill-buffer b)))
(mapc #'kill-buffer show-buffers))) (mapc #'kill-buffer show-buffers)))
@ -99,7 +99,7 @@
collect url))) collect url)))
;;;###autoload ;;;###autoload
(defun +rss-put-sliced-image (spec alt &optional flags) (defun +rss-put-sliced-image-fn (spec alt &optional flags)
"TODO" "TODO"
(cl-letf (((symbol-function #'insert-image) (cl-letf (((symbol-function #'insert-image)
(lambda (image &optional alt _area _slice) (lambda (image &optional alt _area _slice)
@ -108,7 +108,7 @@
(shr-put-image spec alt flags))) (shr-put-image spec alt flags)))
;;;###autoload ;;;###autoload
(defun +rss-render-image-tag-without-underline (dom &optional url) (defun +rss-render-image-tag-without-underline-fn (dom &optional url)
"TODO" "TODO"
(let ((start (point))) (let ((start (point)))
(shr-tag-img dom url) (shr-tag-img dom url)

View file

@ -36,21 +36,21 @@ easier to scroll through.")
(make-directory elfeed-db-directory t) (make-directory elfeed-db-directory t)
;; Ensure elfeed buffers are treated as real ;; Ensure elfeed buffers are treated as real
(add-hook 'doom-real-buffer-functions
(defun +rss-buffer-p (buf) (defun +rss-buffer-p (buf)
(string-match-p "^\\*elfeed" (buffer-name buf))) (string-match-p "^\\*elfeed" (buffer-name buf))))
(add-to-list 'doom-real-buffer-functions #'+rss-buffer-p nil #'eq)
;; Enhance readability of a post ;; Enhance readability of a post
(add-hook 'elfeed-show-mode-hook #'+rss|elfeed-wrap) (add-hook 'elfeed-show-mode-hook #'+rss-elfeed-wrap-h)
(add-hook! 'elfeed-search-mode-hook (add-hook! 'elfeed-search-mode-hook
(add-hook 'kill-buffer-hook #'+rss|cleanup nil t)) (add-hook 'kill-buffer-hook #'+rss-cleanup-h nil t))
;; Large images are annoying to scroll through, because scrolling follows the ;; Large images are annoying to scroll through, because scrolling follows the
;; cursor, so we force shr to insert images in slices. ;; cursor, so we force shr to insert images in slices.
(when +rss-enable-sliced-images (when +rss-enable-sliced-images
(setq-hook! 'elfeed-show-mode-hook (setq-hook! 'elfeed-show-mode-hook
shr-put-image-function #'+rss-put-sliced-image shr-put-image-function #'+rss-put-sliced-image-fn
shr-external-rendering-functions '((img . +rss-render-image-tag-without-underline)))) shr-external-rendering-functions '((img . +rss-render-image-tag-without-underline-fn))))
;; Keybindings ;; Keybindings
(after! elfeed-show (after! elfeed-show
@ -68,7 +68,7 @@ easier to scroll through.")
:when (featurep! +org) :when (featurep! +org)
:after elfeed :after elfeed
:config :config
(setq rmh-elfeed-org-files
(let ((default-directory org-directory)) (let ((default-directory org-directory))
(setq rmh-elfeed-org-files
(mapcar #'expand-file-name +rss-elfeed-files))) (mapcar #'expand-file-name +rss-elfeed-files)))
(elfeed-org)) (elfeed-org))

View file

@ -4,7 +4,7 @@
"The name to use for the twitter workspace.") "The name to use for the twitter workspace.")
;;;###autoload ;;;###autoload
(defun +twitter-display-buffer (buf) (defun +twitter-display-buffer-fn (buf)
"A replacement display-buffer command for `twittering-pop-to-buffer-function' "A replacement display-buffer command for `twittering-pop-to-buffer-function'
that works with the feature/popup module." that works with the feature/popup module."
(let ((win (selected-window))) (let ((win (selected-window)))

View file

@ -3,7 +3,8 @@
(def-package! twittering-mode (def-package! twittering-mode
:commands twit :commands twit
:config :config
(setq twittering-private-info-file (expand-file-name "twittering-mode.gpg" doom-etc-dir) (setq twittering-private-info-file
(expand-file-name "twittering-mode.gpg" doom-etc-dir)
twittering-use-master-password t twittering-use-master-password t
twittering-request-confirmation-on-posting t twittering-request-confirmation-on-posting t
;; twittering-icon-mode t ;; twittering-icon-mode t
@ -35,24 +36,16 @@
(add-hook 'doom-real-buffer-functions #'+twitter-buffer-p) (add-hook 'doom-real-buffer-functions #'+twitter-buffer-p)
(when (featurep! :ui popup) (when (featurep! :ui popup)
(setq twittering-pop-to-buffer-function #'+twitter-display-buffer)) (setq twittering-pop-to-buffer-function #'+twitter-display-buffer-fn))
(after! solaire-mode (after! solaire-mode
(add-hook 'twittering-mode-hook #'solaire-mode)) (add-hook 'twittering-mode-hook #'solaire-mode))
;; Custom header-line for twitter buffers ;; Custom header-line for twitter buffers
(defun +twitter|switch-mode-and-header-line () (add-hook 'twittering-mode-hook
(defun +twitter-switch-mode-and-header-line-h ()
(setq header-line-format mode-line-format (setq header-line-format mode-line-format
mode-line-format nil)) mode-line-format nil)))
(add-hook 'twittering-mode-hook #'+twitter|switch-mode-and-header-line)
(cond ((featurep! :ui doom-modeline +new)
(setq-hook! 'twittering-mode-hook mode-line-format-right nil))
((featurep! :ui doom-modeline)
(def-modeline! 'twitter
'(bar matches " %b " selection-info)
'())
(add-hook! 'twittering-mode-hook (doom-set-modeline 'twitter))))
;; `epa--decode-coding-string' isn't defined in later versions of Emacs 27 ;; `epa--decode-coding-string' isn't defined in later versions of Emacs 27
(unless (fboundp 'epa--decode-coding-string) (unless (fboundp 'epa--decode-coding-string)

View file

@ -65,15 +65,15 @@ Examples:
;;; Hooks ;;; Hooks
;;;###autoload ;;;###autoload
(defun +company|init-backends () (defun +company-init-backends-h ()
"Set `company-backends' for the current buffer." "Set `company-backends' for the current buffer."
(if (not company-mode) (if (not company-mode)
(remove-hook 'change-major-mode-after-body-hook #'+company|init-backends 'local) (remove-hook 'change-major-mode-after-body-hook #'+company-init-backends-h 'local)
(unless (eq major-mode 'fundamental-mode) (unless (eq major-mode 'fundamental-mode)
(setq-local company-backends (+company--backends))) (setq-local company-backends (+company--backends)))
(add-hook 'change-major-mode-after-body-hook #'+company|init-backends nil 'local))) (add-hook 'change-major-mode-after-body-hook #'+company-init-backends-h nil 'local)))
(put '+company|init-backends 'permanent-local-hook t) (put '+company-init-backends-h 'permanent-local-hook t)
;; ;;

View file

@ -27,11 +27,11 @@
;; Allow users to switch between backends on the fly. E.g. C-x C-s followed ;; Allow users to switch between backends on the fly. E.g. C-x C-s followed
;; by C-x C-n, will switch from `company-yasnippet' to ;; by C-x C-n, will switch from `company-yasnippet' to
;; `company-dabbrev-code'. ;; `company-dabbrev-code'.
(def-advice! +company--abort-previous-a (&rest _) (def-advice! +company-abort-previous-a (&rest _)
:before #'company-begin-backend :before #'company-begin-backend
(company-abort))) (company-abort)))
(add-hook 'company-mode-hook #'+company|init-backends) (add-hook 'company-mode-hook #'+company-init-backends-h)
(global-company-mode +1)) (global-company-mode +1))
@ -68,7 +68,10 @@
company-box-max-candidates 50 company-box-max-candidates 50
company-box-icons-alist 'company-box-icons-all-the-icons company-box-icons-alist 'company-box-icons-all-the-icons
company-box-icons-functions company-box-icons-functions
'(+company-box-icons--yasnippet company-box-icons--lsp +company-box-icons--elisp company-box-icons--acphp) '(+company-box-icons--yasnippet-fn
company-box-icons--lsp
+company-box-icons--elisp-fn
company-box-icons--acphp)
company-box-icons-all-the-icons company-box-icons-all-the-icons
`((Unknown . ,(all-the-icons-material "find_in_page" :height 0.8 :face 'all-the-icons-purple)) `((Unknown . ,(all-the-icons-material "find_in_page" :height 0.8 :face 'all-the-icons-purple))
(Text . ,(all-the-icons-material "text_fields" :height 0.8 :face 'all-the-icons-green)) (Text . ,(all-the-icons-material "text_fields" :height 0.8 :face 'all-the-icons-green))
@ -103,11 +106,11 @@
(ElispFeature . ,(all-the-icons-material "stars" :height 0.8 :face 'all-the-icons-orange)) (ElispFeature . ,(all-the-icons-material "stars" :height 0.8 :face 'all-the-icons-orange))
(ElispFace . ,(all-the-icons-material "format_paint" :height 0.8 :face 'all-the-icons-pink)))) (ElispFace . ,(all-the-icons-material "format_paint" :height 0.8 :face 'all-the-icons-pink))))
(defun +company-box-icons--yasnippet (candidate) (defun +company-box-icons--yasnippet-fn (candidate)
(when (get-text-property 0 'yas-annotation candidate) (when (get-text-property 0 'yas-annotation candidate)
'Yasnippet)) 'Yasnippet))
(defun +company-box-icons--elisp (candidate) (defun +company-box-icons--elisp-fn (candidate)
(when (derived-mode-p 'emacs-lisp-mode) (when (derived-mode-p 'emacs-lisp-mode)
(let ((sym (intern candidate))) (let ((sym (intern candidate)))
(cond ((fboundp sym) 'ElispFunction) (cond ((fboundp sym) 'ElispFunction)
@ -121,7 +124,7 @@
:config :config
(setq company-dict-dir (expand-file-name "dicts" doom-private-dir)) (setq company-dict-dir (expand-file-name "dicts" doom-private-dir))
(add-hook 'doom-project-hook (add-hook 'doom-project-hook
(defun +company--enable-project-dicts-h (mode &rest _) (defun +company-enable-project-dicts-h (mode &rest _)
"Enable per-project dictionaries." "Enable per-project dictionaries."
(if (symbol-value mode) (if (symbol-value mode)
(add-to-list 'company-dict-minor-mode-list mode nil #'eq) (add-to-list 'company-dict-minor-mode-list mode nil #'eq)

View file

@ -28,8 +28,9 @@
(insert "~/") (insert "~/")
(call-interactively #'self-insert-command)))) (call-interactively #'self-insert-command))))
(defun +ido--sort-mtime-a () (def-advice! +ido-sort-mtime-a ()
"Sort ido filelist by mtime instead of alphabetically." "Sort ido filelist by mtime instead of alphabetically."
:override #'ido-sort-mtime
(setq ido-temp-list (setq ido-temp-list
(sort ido-temp-list (sort ido-temp-list
(lambda (a b) (lambda (a b)
@ -40,7 +41,6 @@
(cl-loop for x in ido-temp-list (cl-loop for x in ido-temp-list
if (char-equal (string-to-char x) ?.) if (char-equal (string-to-char x) ?.)
collect x))) collect x)))
(advice-add #'ido-sort-mtime :override #'+ido--sort-mtime-a)
(add-hook! (ido-make-file-list ido-make-dir-list) #'ido-sort-mtime) (add-hook! (ido-make-file-list ido-make-dir-list) #'ido-sort-mtime)
;; ;;

View file

@ -114,7 +114,7 @@ information.")
(or (file-in-directory-p file doom-private-dir) (or (file-in-directory-p file doom-private-dir)
(file-in-directory-p file doom-emacs-dir))) (file-in-directory-p file doom-emacs-dir)))
(defun +file-templates|check () (defun +file-templates-check-h ()
"Check if the current buffer is a candidate for file template expansion. It "Check if the current buffer is a candidate for file template expansion. It
must be non-read-only, empty, and there must be a rule in must be non-read-only, empty, and there must be a rule in
`+file-templates-alist' that applies to it." `+file-templates-alist' that applies to it."
@ -143,4 +143,4 @@ must be non-read-only, empty, and there must be a rule in
(yas-reload-all))) (yas-reload-all)))
;; ;;
(add-hook 'find-file-hook #'+file-templates|check) (add-hook 'find-file-hook #'+file-templates-check-h)

View file

@ -6,12 +6,12 @@
:group 'doom-themes) :group 'doom-themes)
;;;###autoload ;;;###autoload
(defun +fold-hideshow-haml-forward-sexp (arg) (defun +fold-hideshow-haml-forward-sexp-fn (arg)
(haml-forward-sexp arg) (haml-forward-sexp arg)
(move-beginning-of-line 1)) (move-beginning-of-line 1))
;;;###autoload ;;;###autoload
(defun +fold-hideshow-forward-block-by-indent (_arg) (defun +fold-hideshow-forward-block-by-indent-fn (_arg)
(let ((start (current-indentation))) (let ((start (current-indentation)))
(forward-line) (forward-line)
(unless (= start (current-indentation)) (unless (= start (current-indentation))
@ -20,7 +20,7 @@
(end-of-line))))) (end-of-line)))))
;;;###autoload ;;;###autoload
(defun +fold-hideshow-set-up-overlay (ov) (defun +fold-hideshow-set-up-overlay-fn (ov)
(when (eq 'code (overlay-get ov 'hs)) (when (eq 'code (overlay-get ov 'hs))
(when (featurep 'vimish-fold) (when (featurep 'vimish-fold)
(overlay-put (overlay-put

View file

@ -18,13 +18,17 @@
;; Packages ;; Packages
(def-package! hideshow ; built-in (def-package! hideshow ; built-in
:commands (hs-toggle-hiding hs-hide-block hs-hide-level hs-show-all hs-hide-all) :commands (hs-toggle-hiding
hs-hide-block
hs-hide-level
hs-show-all
hs-hide-all)
:config :config
(setq hs-hide-comments-when-hiding-all nil (setq hs-hide-comments-when-hiding-all nil
;; Nicer code-folding overlays (with fringe indicators) ;; Nicer code-folding overlays (with fringe indicators)
hs-set-up-overlay #'+fold-hideshow-set-up-overlay) hs-set-up-overlay #'+fold-hideshow-set-up-overlay-fn)
(def-advice! +fold-hideshow*ensure-mode (&rest _) (def-advice! +fold-hideshow-ensure-mode-a (&rest _)
"Ensure `hs-minor-mode' is enabled." "Ensure `hs-minor-mode' is enabled."
:before '(hs-toggle-hiding hs-hide-block hs-hide-level hs-show-all hs-hide-all) :before '(hs-toggle-hiding hs-hide-block hs-hide-level hs-show-all hs-hide-all)
(unless (bound-and-true-p hs-minor-mode) (unless (bound-and-true-p hs-minor-mode)
@ -38,8 +42,8 @@
(yaml-mode "\\s-*\\_<\\(?:[^:]+\\)\\_>" (yaml-mode "\\s-*\\_<\\(?:[^:]+\\)\\_>"
"" ""
"#" "#"
+fold-hideshow-forward-block-by-indent nil) +fold-hideshow-forward-block-by-indent-fn nil)
(haml-mode "[#.%]" "\n" "/" +fold-hideshow-haml-forward-sexp nil) (haml-mode "[#.%]" "\n" "/" +fold-hideshow-haml-forward-sexp-fn nil)
(ruby-mode "class\\|d\\(?:ef\\|o\\)\\|module\\|[[{]" (ruby-mode "class\\|d\\(?:ef\\|o\\)\\|module\\|[[{]"
"end\\|[]}]" "end\\|[]}]"
"#\\|=begin" "#\\|=begin"

View file

@ -98,7 +98,7 @@ Stolen shamelessly from go-mode"
(if fmt (cons (intern fmt) t)))) (if fmt (cons (intern fmt) t))))
;;;###autoload ;;;###autoload
(defun +format*probe (orig-fn) (defun +format-probe-a (orig-fn)
"Use `+format-with' instead, if it is set." "Use `+format-with' instead, if it is set."
(if +format-with (if +format-with
(list +format-with t) (list +format-with t)
@ -119,7 +119,7 @@ formatted text, ERRORS are any errors in string format, and FIRST-DIFF is the
position of the first change in the buffer. position of the first change in the buffer.
See `+format/buffer' for the interactive version of this function, and See `+format/buffer' for the interactive version of this function, and
`+format|buffer' to use as a `before-save-hook' hook." `+format-buffer-h' to use as a `before-save-hook' hook."
(if (not formatter) (if (not formatter)
'no-formatter 'no-formatter
(let ((f-function (gethash formatter format-all--format-table)) (let ((f-function (gethash formatter format-all--format-table))
@ -228,12 +228,12 @@ is selected)."
;; Hooks ;; Hooks
;;;###autoload ;;;###autoload
(defun +format|enable-on-save () (defun +format-enable-on-save-h ()
"Enables formatting on save." "Enables formatting on save."
(add-hook 'before-save-hook #'+format|buffer nil t)) (add-hook 'before-save-hook #'+format-buffer-h nil t))
;;;###autoload ;;;###autoload
(defalias '+format|buffer #'+format/buffer (defalias '+format-buffer-h #'+format/buffer
"Format the source code in the current buffer with minimal feedback. "Format the source code in the current buffer with minimal feedback.
Meant for `before-save-hook'.") Meant for `before-save-hook'.")

View file

@ -25,7 +25,7 @@ Indentation is always preserved when formatting regions.")
;; ;;
;;; Bootstrap ;;; Bootstrap
(defun +format|enable-on-save-maybe () (defun +format-enable-on-save-maybe-h ()
"Enable formatting on save in certain major modes. "Enable formatting on save in certain major modes.
This is controlled by `+format-on-save-enabled-modes'." This is controlled by `+format-on-save-enabled-modes'."
@ -39,7 +39,7 @@ This is controlled by `+format-on-save-enabled-modes'."
(format-all-mode +1))) (format-all-mode +1)))
(when (featurep! +onsave) (when (featurep! +onsave)
(add-hook 'after-change-major-mode-hook #'+format|enable-on-save-maybe)) (add-hook 'after-change-major-mode-hook #'+format-enable-on-save-maybe-h))
;; ;;
@ -47,7 +47,7 @@ This is controlled by `+format-on-save-enabled-modes'."
;; Allow a specific formatter to be used by setting `+format-with', either ;; Allow a specific formatter to be used by setting `+format-with', either
;; buffer-locally or let-bound. ;; buffer-locally or let-bound.
(advice-add #'format-all--probe :around #'+format*probe) (advice-add #'format-all--probe :around #'+format-probe-a)
;; Doom uses a modded `format-all-buffer', which ;; Doom uses a modded `format-all-buffer', which
;; 1. Enables partial reformatting (while preserving leading indentation), ;; 1. Enables partial reformatting (while preserving leading indentation),

View file

@ -3,7 +3,6 @@
(def-package! objed (def-package! objed
:after-call pre-command-hook :after-call pre-command-hook
:config :config
;; Prevent undo actions from exiting edit state ;; Prevent undo actions from exiting edit state
(add-to-list 'objed-keeper-commands 'undo-tree-undo) (add-to-list 'objed-keeper-commands 'undo-tree-undo)
(add-to-list 'objed-keeper-commands 'undo-tree-redo) (add-to-list 'objed-keeper-commands 'undo-tree-redo)
@ -11,21 +10,20 @@
(defvar +objed--extra-face-remaps nil) (defvar +objed--extra-face-remaps nil)
(defun +objed*add-face-remaps (&rest _) (def-advice! +objed-add-face-remaps-a (&rest _)
"Add extra face remaps when objed activates." "Add extra face remaps when objed activates."
:after 'objed--init
(when (memq 'objed-hl (assq 'hl-line face-remapping-alist)) (when (memq 'objed-hl (assq 'hl-line face-remapping-alist))
(push (face-remap-add-relative 'solaire-hl-line-face 'objed-hl) (push (face-remap-add-relative 'solaire-hl-line-face 'objed-hl)
+objed--extra-face-remaps))) +objed--extra-face-remaps)))
(defun +objed*remove-face-remaps (&rest _) (def-advice! +objed-remove-face-remaps-a (&rest _)
"Remove extra face remaps when objed de-activates." "Remove extra face remaps when objed de-activates."
:after 'objed--reset
(unless (memq 'objed-hl (assq 'hl-line face-remapping-alist)) (unless (memq 'objed-hl (assq 'hl-line face-remapping-alist))
(dolist (remap +objed--extra-face-remaps) (dolist (remap +objed--extra-face-remaps)
(face-remap-remove-relative remap)) (face-remap-remove-relative remap))
(setq +objed--extra-face-remaps nil))) (setq +objed--extra-face-remaps nil)))
(advice-add 'objed--init :after #'+objed*add-face-remaps)
(advice-add 'objed--reset :after #'+objed*remove-face-remaps)
(unless (featurep! +manual) (unless (featurep! +manual)
(objed-mode +1))) (objed-mode +1)))

View file

@ -56,19 +56,19 @@
;; confusing than helpful. ;; confusing than helpful.
(advice-add #'dired-k--highlight-by-file-attribyte :override #'ignore) (advice-add #'dired-k--highlight-by-file-attribyte :override #'ignore)
(defun +dired*interrupt-process (orig-fn &rest args) (def-advice! +dired-interrupt-process-a (orig-fn &rest args)
"Fixes dired-k killing git processes too abruptly, leaving behind disruptive "Fixes dired-k killing git processes too abruptly, leaving behind disruptive
.git/index.lock files." .git/index.lock files."
:around #'dired-k--start-git-status
(cl-letf (((symbol-function #'kill-process) (cl-letf (((symbol-function #'kill-process)
(symbol-function #'interrupt-process))) (symbol-function #'interrupt-process)))
(apply orig-fn args))) (apply orig-fn args)))
(advice-add #'dired-k--start-git-status :around #'+dired*interrupt-process)
(defun +dired*dired-k-highlight (orig-fn &rest args) (def-advice! +dired-dired-k-highlight-a (orig-fn &rest args)
"Butt out if the requested directory is remote (i.e. through tramp)." "Butt out if the requested directory is remote (i.e. through tramp)."
:around #'dired-k--highlight
(unless (file-remote-p default-directory) (unless (file-remote-p default-directory)
(apply orig-fn args))) (apply orig-fn args))))
(advice-add #'dired-k--highlight :around #'+dired*dired-k-highlight))
(def-package! ranger (def-package! ranger
@ -84,24 +84,24 @@
(set-popup-rule! "^\\*ranger" :ignore t) (set-popup-rule! "^\\*ranger" :ignore t)
(defun +dired*cleanup-header-line () (def-advice! +dired-cleanup-header-line-a ()
"Ranger fails to clean up `header-line-format' when it is closed, so..." "Ranger fails to clean up `header-line-format' when it is closed, so..."
:before #'ranger-revert
(dolist (buffer (buffer-list)) (dolist (buffer (buffer-list))
(when (buffer-live-p buffer) (when (buffer-live-p buffer)
(with-current-buffer buffer (with-current-buffer buffer
(when (equal header-line-format '(:eval (ranger-header-line))) (when (equal header-line-format '(:eval (ranger-header-line)))
(setq header-line-format nil)))))) (setq header-line-format nil))))))
(advice-add #'ranger-revert :before #'+dired*cleanup-header-line)
(defun +dired*cleanup-mouse1-bind () (def-advice! +dired-cleanup-mouse1-bind-a ()
"Ranger binds an anonymous function to mouse-1 after previewing a buffer "Ranger binds an anonymous function to mouse-1 after previewing a buffer
that prevents the user from escaping the window with the mouse. This command is that prevents the user from escaping the window with the mouse. This command is
never cleaned up if the buffer already existed before ranger was initialized, so never cleaned up if the buffer already existed before ranger was initialized, so
we have to clean it up ourselves." we have to clean it up ourselves."
:after #'ranger-setup-preview
(when (window-live-p ranger-preview-window) (when (window-live-p ranger-preview-window)
(with-current-buffer (window-buffer ranger-preview-window) (with-current-buffer (window-buffer ranger-preview-window)
(local-unset-key [mouse-1])))) (local-unset-key [mouse-1]))))
(advice-add #'ranger-setup-preview :after #'+dired*cleanup-mouse1-bind)
(setq ranger-cleanup-on-disable t (setq ranger-cleanup-on-disable t
ranger-excluded-extensions '("mkv" "iso" "mp4") ranger-excluded-extensions '("mkv" "iso" "mp4")

View file

@ -10,10 +10,9 @@ current line.")
(after! electric (after! electric
(setq-default electric-indent-chars '(?\n ?\^?)) (setq-default electric-indent-chars '(?\n ?\^?))
(defun +electric-indent|char (_c) (add-hook 'electric-indent-functions
(defun +electric-indent-char-fn (_c)
(when (and (eolp) +electric-indent-words) (when (and (eolp) +electric-indent-words)
(save-excursion (save-excursion
(backward-word) (backward-word)
(looking-at-p (concat "\\<" (regexp-opt +electric-indent-words)))))) (looking-at-p (concat "\\<" (regexp-opt +electric-indent-words))))))))
(add-to-list 'electric-indent-functions #'+electric-indent|char nil #'eq))

View file

@ -26,7 +26,7 @@ repository root."
(git-link (git-link--select-remote) beg end))))) (git-link (git-link--select-remote) beg end)))))
;;;###autoload ;;;###autoload
(defun +vc*update-header-line (revision) (defun +vc-update-header-line-a (revision)
"Show revision details in the header-line, instead of the minibuffer. "Show revision details in the header-line, instead of the minibuffer.
Sometimes I forget `git-timemachine' is enabled in a buffer. Putting revision Sometimes I forget `git-timemachine' is enabled in a buffer. Putting revision

View file

@ -10,7 +10,7 @@
(after! git-timemachine (after! git-timemachine
;; HACK Waiting for https://gitlab.com/pidu/git-timemachine/issues/77 ;; HACK Waiting for https://gitlab.com/pidu/git-timemachine/issues/77
(def-advice! +vc--git-timemachine-show-commit-a () (def-advice! +vc-git-timemachine-show-commit-a ()
"Fix `git-timemachine-show-commit'." "Fix `git-timemachine-show-commit'."
:override #'git-timemachine-show-commit :override #'git-timemachine-show-commit
(interactive) (interactive)
@ -29,7 +29,8 @@
;; showing revision details in the minibuffer, show them in ;; showing revision details in the minibuffer, show them in
;; `header-line-format', which has better visibility. ;; `header-line-format', which has better visibility.
(setq git-timemachine-show-minibuffer-details t) (setq git-timemachine-show-minibuffer-details t)
(advice-add #'git-timemachine--show-minibuffer-details :override #'+vc*update-header-line) (advice-add #'git-timemachine--show-minibuffer-details
:override #'+vc-update-header-line-a)
(after! evil (after! evil
;; rehash evil keybindings so they are recognized ;; rehash evil keybindings so they are recognized
@ -50,14 +51,14 @@
(set-yas-minor-mode! 'git-commit-mode) (set-yas-minor-mode! 'git-commit-mode)
(add-hook 'git-commit-mode-hook (add-hook 'git-commit-mode-hook
(defun +vc--enforce-git-commit-conventions-h () (defun +vc-enforce-git-commit-conventions-h ()
"See https://chris.beams.io/posts/git-commit/" "See https://chris.beams.io/posts/git-commit/"
(setq fill-column 72 (setq fill-column 72
git-commit-summary-max-length 50 git-commit-summary-max-length 50
git-commit-style-convention-checks '(overlong-summary-line non-empty-second-line)))) git-commit-style-convention-checks '(overlong-summary-line non-empty-second-line))))
(add-hook 'git-commit-setup-hook (add-hook 'git-commit-setup-hook
(defun +vc--start-in-insert-state-maybe () (defun +vc-start-in-insert-state-maybe ()
"Start git-commit-mode in insert state if in a blank commit message, "Start git-commit-mode in insert state if in a blank commit message,
otherwise in default state." otherwise in default state."
(when (and (bound-and-true-p evil-mode) (when (and (bound-and-true-p evil-mode)

View file

@ -45,7 +45,7 @@ default/fallback account."
(defvar +mu4e-workspace-name "*mu4e*" (defvar +mu4e-workspace-name "*mu4e*"
"TODO") "TODO")
(add-hook 'mu4e-main-mode-hook #'+mu4e|init) (add-hook 'mu4e-main-mode-hook #'+mu4e-init-h)
;;;###autoload ;;;###autoload
(defun =mu4e () (defun =mu4e ()
@ -69,10 +69,10 @@ default/fallback account."
;; ;;
;; Hooks ;; Hooks
(defun +mu4e|init () (defun +mu4e-init-h ()
(add-hook 'kill-buffer-hook #'+mu4e|kill-mu4e nil t)) (add-hook 'kill-buffer-hook #'+mu4e-kill-mu4e-h nil t))
(defun +mu4e|kill-mu4e () (defun +mu4e-kill-mu4e-h ()
;; (prolusion-mail-hide) ;; (prolusion-mail-hide)
(when (+workspace-exists-p +mu4e-workspace-name) (when (+workspace-exists-p +mu4e-workspace-name)
(+workspace/delete +mu4e-workspace-name))) (+workspace/delete +mu4e-workspace-name)))

View file

@ -11,7 +11,7 @@
(def-package! mu4e (def-package! mu4e
:commands (mu4e mu4e-compose-new) :commands mu4e mu4e-compose-new
:init :init
(provide 'html2text) ; disable obsolete package (provide 'html2text) ; disable obsolete package
(setq mu4e-maildir "~/.mail" (setq mu4e-maildir "~/.mail"
@ -89,8 +89,8 @@
(format "%s" (substring maildir 1 (string-match-p "/" maildir 1))))))) (format "%s" (substring maildir 1 (string-match-p "/" maildir 1)))))))
;; Refresh the current view after marks are executed ;; Refresh the current view after marks are executed
(defun +mu4e*refresh (&rest _) (mu4e-headers-rerun-search)) (def-advice! +mu4e-refresh-a (&rest _) :after #'mu4e-mark-execute-all
(advice-add #'mu4e-mark-execute-all :after #'+mu4e*refresh) (mu4e-headers-rerun-search))
(when (featurep! :tools flyspell) (when (featurep! :tools flyspell)
(add-hook 'mu4e-compose-mode-hook #'flyspell-mode)) (add-hook 'mu4e-compose-mode-hook #'flyspell-mode))
@ -152,7 +152,7 @@
(defun +mu4e--mark-seen (docid _msg target) (defun +mu4e--mark-seen (docid _msg target)
(mu4e~proc-move docid (mu4e~mark-check-target target) "+S-u-N")) (mu4e~proc-move docid (mu4e~mark-check-target target) "+S-u-N"))
(delq (assq 'delete mu4e-marks) mu4e-marks) (delq! 'delete mu4e-marks #'assq)
(setf (alist-get 'trash mu4e-marks) (setf (alist-get 'trash mu4e-marks)
(list :char '("d" . "") (list :char '("d" . "")
:prompt "dtrash" :prompt "dtrash"
@ -169,10 +169,10 @@
;; Without it, refiling (archiving), trashing, and flagging (starring) email ;; Without it, refiling (archiving), trashing, and flagging (starring) email
;; won't properly result in the corresponding gmail action, since the marks ;; won't properly result in the corresponding gmail action, since the marks
;; are ineffectual otherwise. ;; are ineffectual otherwise.
(defun +mu4e|gmail-fix-flags (mark msg) (add-hook 'mu4e-mark-execute-pre-hook
(defun +mu4e-gmail-fix-flags-h (mark msg)
(pcase mark (pcase mark
(`trash (mu4e-action-retag-message msg "-\\Inbox,+\\Trash,-\\Draft")) (`trash (mu4e-action-retag-message msg "-\\Inbox,+\\Trash,-\\Draft"))
(`refile (mu4e-action-retag-message msg "-\\Inbox")) (`refile (mu4e-action-retag-message msg "-\\Inbox"))
(`flag (mu4e-action-retag-message msg "+\\Starred")) (`flag (mu4e-action-retag-message msg "+\\Starred"))
(`unflag (mu4e-action-retag-message msg "-\\Starred")))) (`unflag (mu4e-action-retag-message msg "-\\Starred")))))))
(add-hook 'mu4e-mark-execute-pre-hook #'+mu4e|gmail-fix-flags)))

View file

@ -47,11 +47,11 @@ This marks a foldable marker for `outline-minor-mode' in elisp buffers.")
;; Special indentation behavior for `add-hook'; indent like a defun block if ;; Special indentation behavior for `add-hook'; indent like a defun block if
;; it contains `defun' forms and like normal otherwise. ;; it contains `defun' forms and like normal otherwise.
(defun +emacs-lisp--indent-add-hook-fn (indent-point state) (defun +emacs-lisp-indent-add-hook-fn (indent-point state)
(goto-char indent-point) (goto-char indent-point)
(when (looking-at-p "\\s-*(defun ") (when (looking-at-p "\\s-*(defun ")
(lisp-indent-defform state indent-point))) (lisp-indent-defform state indent-point)))
(put 'add-hook 'lisp-indent-function #'+emacs-lisp--indent-add-hook-fn) (put 'add-hook 'lisp-indent-function #'+emacs-lisp-indent-add-hook-fn)
;; Use helpful instead of describe-* from `company' ;; Use helpful instead of describe-* from `company'
(advice-add #'elisp--company-doc-buffer :around #'doom-use-helpful-a) (advice-add #'elisp--company-doc-buffer :around #'doom-use-helpful-a)