diff options
| author | Tassilo Horn <tsdh@gnu.org> | 2019-03-09 08:31:36 +0100 |
|---|---|---|
| committer | Tassilo Horn <tsdh@gnu.org> | 2019-03-09 08:31:36 +0100 |
| commit | a4255984fae2c573f613edf79b03d6b4ba011fe2 (patch) | |
| tree | f87d2de0e364126f93b11717b2d89f98c28789c4 | |
| parent | c06c9639010d08a048d749b3c43e14a13d3530e7 (diff) | |
Improve previous fix (which didn't fix all cases)
| -rw-r--r-- | visual-filename-abbrev.el | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/visual-filename-abbrev.el b/visual-filename-abbrev.el index 26706f3..30b7d8a 100644 --- a/visual-filename-abbrev.el +++ b/visual-filename-abbrev.el @@ -109,15 +109,12 @@ This takes the font into account." ;; When activated from a hook, this function may run before the current ;; buffer is shown in a window. In that case, `font-at' would error with ;; "Specified window is not displaying the current buffer". - (when (eq buffer (current-buffer)) - ;; NOTE: The docs say that object in an conditional display spec is always - ;; a buffer, but actually it sometimes is a window. See the already fixed - ;; bug#34771. - (let ((font (font-at pos (if (windowp buffer) - buffer - (get-buffer-window buffer))))) - (< (visual-filename-abbrev--get-visual-width abbrev font) - (visual-filename-abbrev--get-visual-width filename font))))) + (let ((window (selected-window))) + (when (and window + (eq (window-buffer window) (current-buffer))) + (let ((font (font-at pos window))) + (< (visual-filename-abbrev--get-visual-width abbrev font) + (visual-filename-abbrev--get-visual-width filename font)))))) (defcustom visual-filename-abbrev-predicates (list #'visual-filename-abbrev--abbrev-visually-shorter-p) |
