emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/rec-mode 7b1a375 53/98: rec-mode: provide a sensible lo


From: Stefan Monnier
Subject: [elpa] externals/rec-mode 7b1a375 53/98: rec-mode: provide a sensible log-current-defun for the add-log function.
Date: Thu, 12 Nov 2020 13:18:39 -0500 (EST)

branch: externals/rec-mode
commit 7b1a3750e6d14526c9c480346b4190e052fdc156
Author: Jose E. Marchesi <jemarch@gnu.org>
Commit: Antoine Kalmbach <ane@iki.fi>

    rec-mode: provide a sensible log-current-defun for the add-log function.
---
 etc/rec-mode.el | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/etc/rec-mode.el b/etc/rec-mode.el
index a2674e7..ee719a9 100644
--- a/etc/rec-mode.el
+++ b/etc/rec-mode.el
@@ -2040,6 +2040,21 @@ This command is especially useful with enumerated types."
           (message "record copied to kill ring"))
       (message "Not in a record"))))
 
+;;;; Interacting with other modes
+
+(defun rec-log-current-defun ()
+  "Return the value of the key in the current record, if any.  If
+no key is defined then return the value of the first field in the
+record.  In case the pointer is not in a record then this
+function returns `nil'."
+  (let ((record (rec-current-record))
+        (key (rec-key)))
+    (when record
+      (if key
+          (let ((values (rec-record-assoc key record)))
+            (when values (car values)))
+        (rec-field-value (car (rec-record-fields record)))))))
+
 ;;;; Definition of modes
 
 (defun rec-mode ()
@@ -2058,6 +2073,8 @@ Commands:
   (make-local-variable 'rec-update-p)
   (make-local-variable 'rec-preserve-last-newline)
   (make-local-variable 'rec-editing)
+  (set (make-local-variable 'add-log-current-defun-function)
+       #'rec-log-current-defun)
   (setq rec-editing nil)
   (setq rec-jump-back nil)
   (setq rec-update-p nil)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]