[PATCH] D158196: [emacs] Add regexps for defuns

Luke Lau via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 18 03:22:28 PDT 2023


luke updated this revision to Diff 551453.
luke added a comment.

Handle functions with no arguments and trailing attributes (e.g. nounwind)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158196/new/

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 .+(.*).+")
+  (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.551453.patch
Type: text/x-patch
Size: 1017 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230818/dc80dd4a/attachment.bin>


More information about the llvm-commits mailing list