(next-single-property-change (point) 'lsdb-record nil (point-max)))
(goto-char (point-min)))
+(defun lsdb-current-record ()
+ (let ((record (get-text-property (point) 'lsdb-record)))
+ (unless record
+ (error "There is nothing to follow here"))
+ record))
+
(defun lsdb-current-entry ()
(save-excursion
(beginning-of-line)
(if (looking-at "^[^\t]")
- (let ((record (get-text-property (point) 'lsdb-record))
+ (let ((record (lsdb-current-record))
(completion-ignore-case t))
(completing-read
"Which entry to modify: "
(beginning-of-line)
(unless (symbolp entry-name)
(setq entry-name (intern (downcase entry-name))))
- (when (assq entry-name (cdr (get-text-property (point) 'lsdb-record)))
+ (when (assq entry-name (cdr (lsdb-current-record)))
(error "The entry already exists"))
(let ((marker (point-marker)))
(lsdb-edit-form
(save-excursion
(set-buffer lsdb-buffer-name)
(goto-char ,marker)
- (let* ((record (get-text-property (point) 'lsdb-record))
- (inhibit-read-only t)
- buffer-read-only)
+ (let ((record (lsdb-current-record))
+ (inhibit-read-only t)
+ buffer-read-only)
(setcdr record (cons (cons ',entry-name form) (cdr record)))
(lsdb-puthash (car record) (cdr record)
lsdb-hash-table)
(defun lsdb-mode-delete-entry (&optional entry-name dont-update)
"Delete the entry on the current line."
(interactive)
- (let ((record (get-text-property (point) 'lsdb-record))
+ (let ((record (lsdb-current-record))
entry)
(or entry-name
(setq entry-name (lsdb-current-entry)))
(defun lsdb-mode-edit-entry ()
"Edit the entry on the current line."
(interactive)
- (let* ((record (get-text-property (point) 'lsdb-record))
+ (let* ((record (lsdb-current-record))
(entry-name (intern (downcase (lsdb-current-entry))))
(entry (assq entry-name (cdr record)))
(marker (point-marker)))
(save-excursion
(set-buffer lsdb-buffer-name)
(goto-char ,marker)
- (let* ((record (get-text-property (point) 'lsdb-record))
+ (let* ((record (lsdb-current-record))
(entry (assq ',entry-name (cdr record)))
(inhibit-read-only t)
buffer-read-only)