[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ebdb 4ded2cb 007/350: Be more careful about text props
From: |
Eric Abrahamsen |
Subject: |
[elpa] externals/ebdb 4ded2cb 007/350: Be more careful about text props in record headers |
Date: |
Mon, 14 Aug 2017 11:45:52 -0400 (EDT) |
branch: externals/ebdb
commit 4ded2cb0919403dcca5ad12ddaecce5d667cbe72
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>
Be more careful about text props in record headers
Specifically, how the location of properties affects editing and
deletion of records/fields.
* ebdb-com.el (ebdb-current-field): If point is at eol, scan backward
for field, otherwise scan forward
(ebdb-fmt-record-header): Add the actual name field as a property to
the cached name string.
(ebdb-edit-field): Be more careful about checking where point is.
(ebdb-delete-field-or-record): Ditto.
---
ebdb-com.el | 51 ++++++++++++++++++++++++---------------------------
1 file changed, 24 insertions(+), 27 deletions(-)
diff --git a/ebdb-com.el b/ebdb-com.el
index 6f5f86a..c023439 100644
--- a/ebdb-com.el
+++ b/ebdb-com.el
@@ -362,9 +362,13 @@ If FULL is non-nil record includes the display
information."
(unless (ebdb-current-record) (error "Not a EBDB record"))
(or (get-text-property (point) 'ebdb-field)
(get-text-property
- (next-single-property-change (line-beginning-position)
- 'ebdb-field nil
- (line-end-position))
+ (if (eolp)
+ (previous-single-property-change (point)
+ 'ebdb-field nil
+ (line-beginning-position))
+ (next-single-property-change (point)
+ 'ebdb-field nil
+ (line-end-position)))
'ebdb-field)))
;;; *EBDB* formatting
@@ -561,11 +565,15 @@ This happens in addition to any pre-defined indentation
of STRING."
(when db-chars
(insert db-chars " "))
(setq step (point))
+ ;; We don't actually ask the name field to format itself, just use
+ ;; the cached canonical name string. We do add the field to the
+ ;; string as a text property, however.
(insert (slot-value (ebdb-record-cache record) 'name-string))
(add-text-properties (line-beginning-position) (point)
(list 'ebdb-record record-class))
(add-text-properties step (point)
(list
+ 'ebdb-field (slot-value record 'name)
'face (cdr (assoc record-class
ebdb-name-face-alist)))))
;; Everything else
(when field-list
@@ -1600,16 +1608,15 @@ is more than one), and prompt for the record class to
use."
"Edit the field under point. If point is on the name header of
the record, change the name of the record."
(interactive
- (save-excursion
- (let* ((field (or (get-text-property (point) 'ebdb-record)
- (ebdb-current-field)
- (user-error "Point not in a field"))))
- (list (ebdb-current-record)
- field))))
- (ebdb-with-record-edits (r (list record))
- (if (eieio-object-p field)
- (ebdb-record-change-field record field)
- (ebdb-record-change-name record))))
+ (list (ebdb-current-record)
+ (ebdb-current-field)))
+ (let ((header-p (get-text-property (point) 'ebdb-record)))
+ (ebdb-with-record-edits (r (list record))
+ (if header-p
+ (ebdb-record-change-name record)
+ (if (eieio-object-p field)
+ (ebdb-record-change-field record field)
+ (message "Point not in field"))))))
;;;###autoload
(defun ebdb-edit-foo (record field)
@@ -1672,23 +1679,13 @@ I and J start with zero. Return the modified LIST."
;;;###autoload
(defun ebdb-delete-field-or-record (records field &optional noprompt)
"For RECORDS delete FIELD.
-If FIELD is the `name' field, delete RECORDS from datanbase.
-Interactively, use EBDB prefix \
-\\<ebdb-mode-map>\\[ebdb-do-all-records], see `ebdb-do-all-records',
-and FIELD is the field point is on.
-If prefix NOPROMPT is non-nil, do not confirm deletion."
- ;; The value of FIELD is whatever `ebdb-current-field' returns.
- ;; This way we can identify more accurately what really needs
- ;; to be done.
+
+If point is on the record header (within the name), delete
+RECORDS from the database. If prefix NOPROMPT is non-nil, do not
+confirm deletion."
(interactive
(list (ebdb-do-records) (ebdb-current-field) current-prefix-arg))
- (unless field (error "Not a field"))
(setq records (ebdb-record-list records))
- ;; TODO: Will this delete the record if we try to delete an AKA? We
- ;; need a less ambiguous way of knowing if the record should be
- ;; deleted. Probably `ebdb-fmt-record-header' should lay some
- ;; special text property on the header name, and we should check for
- ;; that.
(if (get-text-property (point) 'ebdb-record)
(ebdb-delete-records records noprompt)
(ebdb-with-record-edits (record records)
- [elpa] branch externals/ebdb created (now acaf3d0), Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 6aa15d2 003/350: Change interactive defs for move/copy-records, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 6c79908 001/350: Test, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 849159d 008/350: Add ebdb-search-database, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 406b700 011/350: Change keybindings of record/field copy commands, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb baa9636 005/350: Complement ebdb-create-record with ebdb-create-record-extended, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 7b8b00f 013/350: Remap binding of ebdb in *EBDB* buffers, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 4ded2cb 007/350: Be more careful about text props in record headers,
Eric Abrahamsen <=
- [elpa] externals/ebdb e760dad 006/350: Fix quoting bug in ebdb-fmt-record-header, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb e0b4d17 016/350: Provide keybindings for clone-buffer and rename-buffer, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 696d6ba 018/350: Document buffer manipulation commands in the manual, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 4633492 023/350: Improve ebdb-field-user docstring, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb ece1a35 017/350: Stray "arg" arg left in create-record-extended, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb c4ea244 021/350: Add new ebdb-field-id field, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 5fe2bf6 020/350: Add ebdb-field-obfuscated abstract field class, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 4b8ce76 024/350: Move point to next record when adding a mark, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 20f1ea2 025/350: Add command to unmark all records, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 9a2fd46 022/350: Merge branch 'master' into buff, Eric Abrahamsen, 2017/08/14