aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBenjamin Barenblat <bbaren@mit.edu>2014-10-20 13:58:59 -0400
committerBenjamin Barenblat <bbaren@mit.edu>2014-10-20 14:05:17 -0400
commitd5a49a857b4986dec2a0a6c90f701bc09ebcf81d (patch)
tree1ba151001c57b990dc91c1ec1c9bf862a1d86a7a
parentdd8373fb571f93cf3bf824777e00278979ef2e21 (diff)
emacs: Query Emacs display table to determine ellipsis stringHEADmaster
Emacs has a slot in its display table, 'selective-display, which it uses to store the character(s) it displays when text gets elided. This commit ensures notmuch does not assume that string is ‘...’ – instead, notmuch examines the display table and bases computations on its actual contents.
-rw-r--r--AUTHORS1
-rw-r--r--NEWS7
-rw-r--r--emacs/notmuch-lib.el8
-rw-r--r--emacs/notmuch-tree.el2
-rw-r--r--emacs/notmuch.el5
5 files changed, 20 insertions, 3 deletions
diff --git a/AUTHORS b/AUTHORS
index 6d0f2de8..593e4752 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -25,6 +25,7 @@ Here is an incomplete list of other people that have made
contributions to Notmuch (whether by code, bug reporting/fixes,
ideas, inspiration, testing or feedback):
+Benjamin Barenblat
Martin Krafft
Keith Packard
Jamey Sharp
diff --git a/NEWS b/NEWS
index 63fdaa71..7826d45e 100644
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,13 @@ Expanded default saved search settings
The default saved searches now include several more common searches,
as well as shortcut keys for `notmuch-jump`.
+Use the display table to determine the ellipsis characters
+
+ Notmuch now examines the Emacs display table to determine the
+ characters it will use when eliding text from lengthy fields (e.g.,
+ the author field in search mode). Thus, if you prefer some string
+ other than `...`, notmuch will use it.
+
Library changes
---------------
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 1e166c6a..9ad4ab1e 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -465,6 +465,14 @@ This replaces spaces, percents, and double quotes in STR with
(kill-new "")
(message "Nothing to stash!")))
+(defun notmuch-common-selective-display-string ()
+ "Determine the selective display string for the current buffer.
+This is usually `...', but it can be reset."
+ (display-table-slot (or (window-display-table)
+ buffer-display-table
+ standard-display-table)
+ 'selective-display))
+
;;
(defun notmuch-remove-if-not (predicate list)
diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index e859cc24..19c35ee4 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -669,7 +669,7 @@ unchanged ADDRESS if parsing fails."
(setq notmuch-tree-previous-subject bare-subject)
(propertize (format format-string
(if (string= previous-subject bare-subject)
- " ..."
+ (concat " " selective-display-string)
bare-subject))
'face face)))
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index b44a907a..62f4c757 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -689,6 +689,7 @@ non-authors is found, assume that all of the authors match."
(save-match-data
(let* ((formatted-authors (format format-string authors))
(formatted-sample (format format-string ""))
+ (selective-display-string (notmuch-common-selective-display-string))
(visible-string formatted-authors)
(invisible-string "")
(padding ""))
@@ -697,7 +698,7 @@ non-authors is found, assume that all of the authors match."
(if (> (length formatted-authors)
(length formatted-sample))
(let ((visible-length (- (length formatted-sample)
- (length "... "))))
+ (length (concat selective-display-string " ")))))
;; Truncate the visible string according to the width of
;; the display string.
(setq visible-string (substring formatted-authors 0 visible-length)
@@ -717,7 +718,7 @@ non-authors is found, assume that all of the authors match."
;; after `invisible-string'.
(setq padding (make-string (- (length formatted-sample)
(length visible-string)
- (length "..."))
+ (length selective-display-string))
? ))))
;; Use different faces to show matching and non-matching authors.