mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-25 04:18:08 +01:00
emacs: Record part p-list in a text property
This is similar to what we already do with the message p-list, though we apply the part's text property to the whole part's text, in contrast with the message p-list, which is (rather obscurely) only applied to the first character.
This commit is contained in:
parent
6bbb91f8b6
commit
04725cfbe5
2 changed files with 31 additions and 1 deletions
|
@ -360,6 +360,18 @@ OBJECT."
|
||||||
below
|
below
|
||||||
string))
|
string))
|
||||||
|
|
||||||
|
(defun notmuch-map-text-property (start end prop func &optional object)
|
||||||
|
"Transform text property PROP using FUNC.
|
||||||
|
|
||||||
|
Applies FUNC to each distinct value of the text property PROP
|
||||||
|
between START and END of OBJECT, setting PROP to the value
|
||||||
|
returned by FUNC."
|
||||||
|
(while (< start end)
|
||||||
|
(let ((value (get-text-property start prop object))
|
||||||
|
(next (next-single-property-change start prop object end)))
|
||||||
|
(put-text-property start next prop (funcall func value) object)
|
||||||
|
(setq start next))))
|
||||||
|
|
||||||
(defun notmuch-logged-error (msg &optional extra)
|
(defun notmuch-logged-error (msg &optional extra)
|
||||||
"Log MSG and EXTRA to *Notmuch errors* and signal MSG.
|
"Log MSG and EXTRA to *Notmuch errors* and signal MSG.
|
||||||
|
|
||||||
|
|
|
@ -900,7 +900,17 @@ If HIDE is non-nil then initially hide this part."
|
||||||
;; Ensure that the part ends with a carriage return.
|
;; Ensure that the part ends with a carriage return.
|
||||||
(unless (bolp)
|
(unless (bolp)
|
||||||
(insert "\n"))
|
(insert "\n"))
|
||||||
(notmuch-show-create-part-overlays msg beg (point) hide)))
|
(notmuch-show-create-part-overlays msg beg (point) hide)
|
||||||
|
;; Record part information. Since we already inserted subparts,
|
||||||
|
;; don't override existing :notmuch-part properties.
|
||||||
|
(notmuch-map-text-property beg (point) :notmuch-part
|
||||||
|
(lambda (v) (or v part)))
|
||||||
|
;; Make :notmuch-part front sticky and rear non-sticky so it stays
|
||||||
|
;; applied to the beginning of each line when we indent the message.
|
||||||
|
(notmuch-map-text-property beg (point) 'front-sticky
|
||||||
|
(lambda (v) (pushnew :notmuch-part v)))
|
||||||
|
(notmuch-map-text-property beg (point) 'rear-nonsticky
|
||||||
|
(lambda (v) (pushnew :notmuch-part v)))))
|
||||||
|
|
||||||
(defun notmuch-show-insert-body (msg body depth)
|
(defun notmuch-show-insert-body (msg body depth)
|
||||||
"Insert the body BODY at depth DEPTH in the current thread."
|
"Insert the body BODY at depth DEPTH in the current thread."
|
||||||
|
@ -1404,6 +1414,14 @@ Some useful entries are:
|
||||||
(notmuch-show-move-to-message-top)
|
(notmuch-show-move-to-message-top)
|
||||||
(get-text-property (point) :notmuch-message-properties)))
|
(get-text-property (point) :notmuch-message-properties)))
|
||||||
|
|
||||||
|
(defun notmuch-show-get-part-properties ()
|
||||||
|
"Return the properties of the innermost part containing point.
|
||||||
|
|
||||||
|
This is the part property list retrieved from the CLI. Signals
|
||||||
|
an error if there is no part containing point."
|
||||||
|
(or (get-text-property (point) :notmuch-part)
|
||||||
|
(error "No message part here")))
|
||||||
|
|
||||||
(defun notmuch-show-set-prop (prop val &optional props)
|
(defun notmuch-show-set-prop (prop val &optional props)
|
||||||
(let ((inhibit-read-only t)
|
(let ((inhibit-read-only t)
|
||||||
(props (or props
|
(props (or props
|
||||||
|
|
Loading…
Reference in a new issue