[PATCH] D158196: [emacs] Add regexps for defuns
Luke Lau via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 17 09:18:56 PDT 2023
luke created this revision.
luke added reviewers: goldstein.w.n, nikic, melver, artagnon.
Herald added subscribers: asb, pmatos, StephenFan.
Herald added a project: All.
luke requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Previously `M-x mark-defun` and friends wouldn't work properly, and would
highlight something at the top of the buffer. This adds a regexp for top-level
functions so the defun functions should work as expected, and also adds a
regexp for extracting their name so which-function-mode should work now too.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D158196
Files:
llvm/utils/emacs/llvm-mode.el
Index: llvm/utils/emacs/llvm-mode.el
===================================================================
--- llvm/utils/emacs/llvm-mode.el
+++ llvm/utils/emacs/llvm-mode.el
@@ -95,12 +95,21 @@
`(,(regexp-opt '("uselistorder" "uselistorder_bb") 'symbols) . font-lock-keyword-face))
"Syntax highlighting for LLVM.")
+(defun llvm-current-defun-name ()
+ "The `add-log-current-defun' function in LLVM mode."
+ (save-excursion
+ (end-of-line)
+ (if (re-search-backward "^[ \t]*define[ \t]+.+[ \t]+@\\(.+\\)(.+)" nil t)
+ (match-string-no-properties 1))))
+
;;;###autoload
(define-derived-mode llvm-mode prog-mode "LLVM"
"Major mode for editing LLVM source files.
\\{llvm-mode-map}
Runs `llvm-mode-hook' on startup."
(setq font-lock-defaults `(llvm-font-lock-keywords))
+ (setq-local defun-prompt-regexp "^[ \t]*define[ \t]+.+[ \t]+ at .+(.+)[ \t]*")
+ (setq-local add-log-current-defun-function #'llvm-current-defun-name)
(setq-local comment-start ";"))
;; Associate .ll files with llvm-mode
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158196.551171.patch
Type: text/x-patch
Size: 1021 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230817/115c17f2/attachment.bin>
More information about the llvm-commits
mailing list