[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/rec-mode 3e47acf 05/98: rec-mode improvements.
From: |
Stefan Monnier |
Subject: |
[elpa] externals/rec-mode 3e47acf 05/98: rec-mode improvements. |
Date: |
Thu, 12 Nov 2020 13:18:29 -0500 (EST) |
branch: externals/rec-mode
commit 3e47acfcb78e1f745a1c557279284807ced72a1d
Author: Jose Marchesi <jco@wilhelm.(none)>
Commit: Antoine Kalmbach <ane@iki.fi>
rec-mode improvements.
---
etc/rec-mode.el | 56 +++++++++++++++++++++++---------------------------------
1 file changed, 23 insertions(+), 33 deletions(-)
diff --git a/etc/rec-mode.el b/etc/rec-mode.el
index 84b11c3..bac02e7 100644
--- a/etc/rec-mode.el
+++ b/etc/rec-mode.el
@@ -300,36 +300,19 @@ nil"
(defun rec-insert-field (field)
"Insert the written form of FIELD in the current buffer"
- (when (and (listp field)
- (equal (car field) 'field))
- (when (rec-insert-field-name (cadr field))
+ (when (rec-field-p field)
+ (when (rec-insert-field-name (rec-field-name field))
(insert " ")
- (rec-insert-field-value (nth 2 field)))))
-
-(defun rec-insert-record (record &optional fields)
- "Insert the written form of RECORD in the current buffer.
-
-If FIELDS is specified, it is a list of fields to include in the
-insertion. If a field in the list does not exist in the record
-it is ignored."
- (when (and (listp record)
- (equal (car record) 'record))
- (rec-insert-record-2 (cdr record) fields)))
-
-(defun rec-insert-record-2 (record fields)
- "Insert the written form of RECORD in the current buffer.
-Recursive part"
- (when (and record (listp record))
- (let ((elem (car record)))
- (cond
- ((and (not fields)
- (equal (car elem) 'comment))
- (rec-insert-comment elem))
- ((and (equal (car elem) 'field)
- (or (not fields)
- (member (nth 1 elem) fields)))
- (rec-insert-field elem))))
- (rec-insert-record-2 (cdr record) fields)))
+ (rec-insert-field-value (rec-field-value field)))))
+
+(defun rec-insert-record (record)
+ "Insert the written form of RECORD in the current buffer."
+ (when (rec-record-p record)
+ (mapcar (lambda (elem)
+ (cond
+ ((rec-comment-p elem) (rec-insert-comment elem))
+ ((rec-field-p elem) (rec-insert-field elem))))
+ (rec-record-fields record))))
;;;; Operations on record structures
;;
@@ -423,10 +406,17 @@ If no such field exists in RECORD then nil is returned."
(when (rec-field-p field)
(nth 3 field)))
+(defun rec-field-set-value (field value)
+ "Return FIELD with its value replaced by VALUE."
+ (list 'field
+ (rec-field-position field)
+ (rec-field-name field)
+ value))
+
(defun rec-field-trim-value (field)
- "Trim the value of the given field."
+ "Return FIELD with its value trimmed."
(when (rec-field-p field)
- (let ((value (nth 2 field))
+ (let ((value (rec-field-value field))
c)
(with-temp-buffer
(insert value)
@@ -445,7 +435,7 @@ If no such field exists in RECORD then nil is returned."
(delete-region (point) (point-max))
(setq value (buffer-substring-no-properties (point-min)
(point-max))))
- (setcar (cddr field) value))))
+ (rec-field-set-value field value))))
;;;; Get entities under pointer
;;
@@ -1553,7 +1543,7 @@ records of the current type"
(save-excursion
(let ((buffer-read-only nil)
(field (rec-current-field)))
- (rec-field-trim-value field)
+ (setq field (rec-field-trim-value field))
(rec-delete-field)
(rec-insert-field field))))
- [elpa] externals/rec-mode 0731ca5 11/98: ob-rec.el imported in the repo., (continued)
- [elpa] externals/rec-mode 0731ca5 11/98: ob-rec.el imported in the repo., Stefan Monnier, 2020/11/12
- [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 <=
- [elpa] externals/rec-mode aa86480 08/98: rec-mode: several fixes., Stefan Monnier, 2020/11/12
- [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