[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/rec-mode aa86480 08/98: rec-mode: several fixes.
From: |
Stefan Monnier |
Subject: |
[elpa] externals/rec-mode aa86480 08/98: rec-mode: several fixes. |
Date: |
Thu, 12 Nov 2020 13:18:30 -0500 (EST) |
branch: externals/rec-mode
commit aa86480009b0f101f3022d5c6fc09150b5136237
Author: Jose E. Marchesi <jemarch@gnu.org>
Commit: Antoine Kalmbach <ane@iki.fi>
rec-mode: several fixes.
---
etc/rec-mode.el | 75 ++++++++++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 64 insertions(+), 11 deletions(-)
diff --git a/etc/rec-mode.el b/etc/rec-mode.el
index 2cab3b6..963eba8 100644
--- a/etc/rec-mode.el
+++ b/etc/rec-mode.el
@@ -117,6 +117,7 @@ Valid values are `edit' and `navigation'. The default is
`navigation'"
(define-key map "\C-cs" 'rec-cmd-search)
(define-key map "\C-cm" 'rec-cmd-trim-field-value)
(define-key map "\C-cc" 'rec-cmd-compile)
+ (define-key map "\C-cI" 'rec-cmd-show-info)
(define-key map [remap move-beginning-of-line] 'rec-cmd-beginning-of-line)
(define-key map (kbd "TAB") 'rec-cmd-goto-next-field)
(define-key map (concat "\C-c" (kbd "RET")) 'rec-cmd-jump)
@@ -134,6 +135,7 @@ Valid values are `edit' and `navigation'. The default is
`navigation'"
(define-key map "T" 'rec-edit-type)
(define-key map "B" 'rec-edit-buffer)
(define-key map "A" 'rec-cmd-append-field)
+ (define-key map "I" 'rec-cmd-show-info)
(define-key map "t" 'rec-cmd-show-descriptor)
(define-key map "l" 'rec-cmd-sel)
(define-key map "s" 'rec-cmd-search)
@@ -335,6 +337,10 @@ nil"
(when (rec-record-p record)
(nth 2 record)))
+(defun rec-record-descriptor-p (record)
+ "Determine if the given record is a descriptor."
+ (not (null (rec-record-assoc '("%rec") record))))
+
(defun rec-record-assoc (name record)
"Get a list with the values of the fields in RECORD named NAME.
@@ -964,6 +970,13 @@ the result buffer."
(widen)
(unless (rec-goto-type type)
(message "No records of the requested type were found."))
+ ;; Show the first data record of this type, if it exists.
+ (if (and (not type)
+ (save-excursion
+ (let ((record-type (rec-record-type)))
+ (and (rec-goto-next-rec)
+ (equal (rec-record-type) record-type)))))
+ (rec-goto-next-rec))
(rec-show-record))
(defun rec-show-record ()
@@ -980,9 +993,10 @@ the result buffer."
(defun rec-set-mode-line (str)
"Set the modeline in rec buffers."
- (setq mode-line-buffer-identification
- (list 20
- "%b " str)))
+ (when str
+ (setq mode-line-buffer-identification
+ (list 20
+ "%b " str))))
(defun rec-set-head-line (str)
"Set the headline in rec buffers."
@@ -1357,10 +1371,16 @@ record. Interactive version."
file. Interactive version."
(interactive)
(widen)
- (if (save-excursion
- (not (rec-goto-next-rec)))
- (message "No more records")
- (rec-goto-next-rec))
+ (let ((record-type (rec-record-type)))
+ (if (save-excursion
+ (and (rec-goto-next-rec)
+ (equal (rec-record-type) record-type)
+ (not (rec-record-descriptor-p (rec-current-record)))))
+ (rec-goto-next-rec)
+ (if (not (rec-record-type))
+ (message "No more records")
+ (message (concat "No more records of type "
+ (rec-record-type))))))
(unless rec-editing
(rec-show-record)))
@@ -1369,10 +1389,16 @@ file. Interactive version."
the file. Interactive version."
(interactive)
(widen)
- (if (save-excursion
- (not (rec-goto-previous-rec)))
- (message "No more records")
- (rec-goto-previous-rec))
+ (let ((record-type (rec-record-type)))
+ (if (save-excursion
+ (and (rec-goto-previous-rec)
+ (equal (rec-record-type) record-type)
+ (not (rec-record-descriptor-p (rec-current-record)))))
+ (rec-goto-previous-rec)
+ (if (not (rec-record-type))
+ (message "No more records")
+ (message (concat "No more records of type "
+ (rec-record-type))))))
(unless rec-editing
(rec-show-record)))
@@ -1571,6 +1597,33 @@ records of the current type"
(setq cmd (concat cmd tmpfile)))
(compilation-start cmd)))
+(defun rec-cmd-show-info ()
+ "Show information about the recfile in the modeline."
+ (interactive)
+ (let ((cur-buf (current-buffer))
+ (filename (if buffer-file-name
+ buffer-file-name
+ (make-temp-file "rec-mode-")))
+ (msg ""))
+ (if (not buffer-file-name)
+ (with-temp-file tmpfile
+ (insert-buffer cur-buf)))
+ (with-temp-buffer
+ (call-process rec-recinf
+ nil ; infile
+ t ; output to current buffer
+ nil ; display
+ filename)
+ (setq msg (buffer-substring-no-properties (point-min)
+ (point-max))))
+ ;; Delete temporary file.
+ (if (not buffer-file-name)
+ (delete-file filename))
+ ;; Show the message.
+ (setq msg (replace-regexp-in-string "\n$" "" msg))
+ (setq msg (replace-regexp-in-string "\n" ", " msg))
+ (message msg)))
+
(defun rec-cmd-beginning-of-line ()
"Move the point to the beginning of the current line.
- [elpa] externals/rec-mode a1e21e1 14/98: Added %typedef to the list of keywords., (continued)
- [elpa] externals/rec-mode a1e21e1 14/98: Added %typedef to the list of keywords., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode 06ec5c5 17/98: ob-rec: support for :sort and minor fixes., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode 2f8aa87 16/98: ob-rec: support for :sort and minor fixes., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode fbd02a9 24/98: rec-mode: field names are no longer lists of parts., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode 0b52532 18/98: ob-rec: support for :sort and minor fixes., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode 18e9e4a 23/98: rec-mode: editing of individual fields now works., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode 424eb72 25/98: rec-mode: fixes in goto-type and show-type., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode f063506 26/98: rec-mode: misc small fixes., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode 0f09c3f 33/98: rec-mode: support editing boolean fields as special enum values., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode 3e47acf 05/98: rec-mode improvements., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode aa86480 08/98: rec-mode: several fixes.,
Stefan Monnier <=
- [elpa] externals/rec-mode 6292f55 09/98: syntax-check fixes., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode 4413688 38/98: rec-mode: new functions returning properties of the current record set., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode 1982af5 42/98: rec-mode: allow the user to cancel the edit date operation by quitting the calendar window., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode eba1923 36/98: rec-mode: presentation of continuation lines in navigation modes, and other improvements., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode 87abd92 49/98: rec-mode: new command rec-cmd-statistics., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode 7b1a375 53/98: rec-mode: provide a sensible log-current-defun for the add-log function., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode 33e106f 54/98: rec-mode: improve rec-log-current-defun so it works in all cases., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode da7b8c0 57/98: rec-mode: rec-end-of-field-pos now works properly when a field ends with the end of file mark., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode e20b7dd 63/98: rec-mode: don't hide continuation lines in editing modes after editing a field., Stefan Monnier, 2020/11/12
- [elpa] externals/rec-mode f39f1a0 66/98: rec-mode: be smart assigning letters to enumerated entries., Stefan Monnier, 2020/11/12