[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-recutils] [PATCH] rec-mode: fix error when saving a newly created f
From: |
Daiki Ueno |
Subject: |
[bug-recutils] [PATCH] rec-mode: fix error when saving a newly created file |
Date: |
Mon, 09 Apr 2012 11:45:41 +0900 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.95 (gnu/linux) |
Hi,
Perhaps this is the same issue as TODO 14. I get a "Wrong type
argument: number-or-marker-p, nil" error, when I open a non-existing
file and finish editing. In that case, an erroneous value is set to
rec-buffer-descriptors:
((descriptor error: #<marker in no buffer>)
(descriptor cannot #<marker in no buffer>)
(descriptor read #<marker in no buffer>)
(descriptor file #<marker in no buffer>)
(descriptor /home/ueno/recutils/foo\.rec #<marker in no buffer>))
So I guess this could be fixed by feeding data to recinf from the buffer
instead of the file. Here is a patch.
2012-04-09 Daiki Ueno <address@hidden>
rec-mode: fix error when rec-finish-editing on newly created file.
* etc/rec-mode.el (rec-update-buffer-descriptors): Don't assume
that the current buffer is already saved on the disk.
>From 5db6934c2ab84080b72bfc7663db9495640dbfda Mon Sep 17 00:00:00 2001
From: Daiki Ueno <address@hidden>
Date: Mon, 9 Apr 2012 11:29:10 +0900
Subject: [PATCH] rec-mode: fix error when rec-finish-editing on newly created
file.
---
etc/rec-mode.el | 54 +++++++++++++++++++++++++++++-------------------------
1 files changed, 29 insertions(+), 25 deletions(-)
diff --git a/etc/rec-mode.el b/etc/rec-mode.el
index 48b3317..ceafca7 100644
--- a/etc/rec-mode.el
+++ b/etc/rec-mode.el
@@ -582,31 +582,35 @@ The current record is the record where the pointer is"
"Get a list of the record descriptors in the current buffer."
(message "Updating record descriptors...")
(setq rec-buffer-descriptors
- (save-excursion
- (let ((rec-file-name (if buffer-file-name
- buffer-file-name
- ""))
- descriptors records)
- ;; Call 'recinf' to get the list of record descriptors in
- ;; sexp format.
- (with-temp-buffer
- (call-process rec-recinf
- nil ; infile
- t ; output to current buffer
- nil ; display
- "-S" "-d" rec-file-name)
- (goto-char (point-min))
- (insert "(")
- (goto-char (point-max))
- (insert ")")
- (setq descriptors (read (buffer-substring-no-properties
(point-min) (point-max)))))
- ;; Calculate the value of 'rec-buffer-descriptors'.
- (mapcar (lambda (descriptor)
- (let ((marker (make-marker)))
- (set-marker marker (rec-record-position descriptor))
- (setq records (cons (list 'descriptor descriptor
marker) records))))
- descriptors)
- (reverse records))))
+ (let ((buffer (generate-new-buffer "Rec Inf "))
+ descriptors records status)
+ (unwind-protect
+ (progn
+ ;; Call 'recinf' to get the list of record descriptors in
+ ;; sexp format.
+ (setq status (call-process-region (point-min) (point-max)
+ rec-recinf
+ nil ; delete
+ buffer
+ nil ; display
+ "-S" "-d"))
+ (if (/= status 0)
+ (error "recinf returned error: %d" status))
+ (with-current-buffer buffer
+ (goto-char (point-min))
+ (insert "(")
+ (goto-char (point-max))
+ (insert ")")
+ (setq descriptors (read (point-min-marker)))))
+ (kill-buffer buffer))
+ ;; Calculate the value of 'rec-buffer-descriptors'.
+ (mapcar (lambda (descriptor)
+ (let ((marker (make-marker)))
+ (set-marker marker (rec-record-position descriptor))
+ (setq records (cons (list 'descriptor descriptor marker)
+ records))))
+ descriptors)
+ (reverse records)))
(message ""))
(defun rec-update-buffer-descriptors-xxx ()
--
1.7.7.6
Regards,
--
Daiki Ueno
- [bug-recutils] [PATCH] rec-mode: fix error when saving a newly created file,
Daiki Ueno <=