feat(emacs-lisp,lispy): recognize ;;* outline headings

Permit `;;* ...` be recognized by imenu and outline-minor-mode (and
outline's commands). This also patches Lispy to reflect this new
configuration (if :lang emacs-lisp is active).

Close: #6732
Co-authored-by: LemonBreezes <LemonBreezes@users.noreply.github.com>
This commit is contained in:
Henrik Lissner 2022-10-28 02:44:27 +02:00
parent 6887998c23
commit a0ccb6b95b
No known key found for this signature in database
GPG key ID: B60957CA074D39A3
3 changed files with 19 additions and 4 deletions

View file

@ -22,7 +22,15 @@
(local-set-key (vector 'remap (lookup-key lispy-mode-map (kbd "TAB"))) #'completion-at-point)))
:config
(setq lispy-close-quotes-at-end-p t)
(add-hook 'lispy-mode-hook #'turn-off-smartparens-mode))
(add-hook 'lispy-mode-hook #'turn-off-smartparens-mode)
(when (modulep! :lang emacs-lisp)
(setq lispy-outline
(concat
;; `lispy-mode' requires `lispy-outline' start with ^
(unless (string-prefix-p "^" +emacs-lisp-outline-regexp) "^")
+emacs-lisp-outline-regexp))
(advice-add #'lispy-outline-level :override #'+emacs-lisp-outline-level)))
(use-package! lispyville

View file

@ -28,6 +28,12 @@ to a pop up buffer."
(kill-buffer buffer))))
(current-buffer)))
;;;###autoload
(defun +emacs-lisp-outline-level ()
"Return outline level for comment at point.
Intended to replace `lisp-outline-level'."
(- (match-end 1) (match-beginning 1)))
;;
;;; Handlers
@ -232,7 +238,7 @@ https://emacs.stackexchange.com/questions/10230/how-to-indent-keywords-aligned"
(defun +emacs-lisp-extend-imenu-h ()
"Improve imenu support in `emacs-lisp-mode' for Doom's APIs."
(setq imenu-generic-expression
`(("Section" "^[ \t]*;;;;*[ \t]+\\([^\n]+\\)" 1)
`(("Section" "^[ \t]*;;;*\\**[ \t]+\\([^\n]+\\)" 1)
("Evil commands" "^\\s-*(evil-define-\\(?:command\\|operator\\|motion\\) +\\(\\_<[^ ()\n]+\\_>\\)" 1)
("Unit tests" "^\\s-*(\\(?:ert-deftest\\|describe\\) +\"\\([^\")]+\\)\"" 1)
("Package" "^\\s-*\\(?:;;;###package\\|(\\(?:package!\\|use-package!?\\|after!\\)\\) +\\(\\_<[^ ()\n]+\\_>\\)" 1)

View file

@ -3,7 +3,7 @@
(defvar +emacs-lisp-enable-extra-fontification t
"If non-nil, highlight special forms, and defined functions and variables.")
(defvar +emacs-lisp-outline-regexp "[ \t]*;;;;* [^ \t\n]"
(defvar +emacs-lisp-outline-regexp "[ \t]*;;;\\(;*\\**\\) [^ \t\n]"
"Regexp to use for `outline-regexp' in `emacs-lisp-mode'.
This marks a foldable marker for `outline-minor-mode' in elisp buffers.")
@ -60,7 +60,8 @@ See `+emacs-lisp-non-package-mode' for details.")
mode-name "Elisp"
;; Don't treat autoloads or sexp openers as outline headers, we have
;; hideshow for that.
outline-regexp +emacs-lisp-outline-regexp)
outline-regexp +emacs-lisp-outline-regexp
outline-level #'+emacs-lisp-outline-level)
;; Fixed indenter that intends plists sensibly.
(advice-add #'calculate-lisp-indent :override #'+emacs-lisp--calculate-lisp-indent-a)