summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Zubarev <dvzubarev@yandex.ru>2024-03-07 20:16:22 +0300
committerJoão Távora <joaotavora@gmail.com>2026-01-10 12:03:08 +0000
commit1d9dd90f77a594cd50b368e6efc85d44539ec209 (patch)
tree27d9da0907e79f01a9fa32b8ba7d2638e31da02f
parentc7f57beb72fb8433ce0be0655bbcb9954437a692 (diff)
Close #31: Switch to base buffer when updating imenu
Fix #30. It is done to assure that imenu is updated only once for all indirect buffers. * breadcrumb.el (bc--ipath-alist): switch to base buffer. Co-authored-by: João Távora <joaotavora@gmail.com>
-rw-r--r--breadcrumb.el45
1 files changed, 23 insertions, 22 deletions
diff --git a/breadcrumb.el b/breadcrumb.el
index 0abe57c..1dc3ed5 100644
--- a/breadcrumb.el
+++ b/breadcrumb.el
@@ -235,28 +235,29 @@ These structures don't have a `breadcrumb-region' property on."
(defun bc--ipath-alist ()
"Return `imenu--index-alist', maybe arrange for its update."
- (let ((nochangep (= (buffer-chars-modified-tick) bc--last-update-tick))
- (buf (current-buffer)))
- (unless nochangep
- (setq bc--last-update-tick (buffer-chars-modified-tick))
- (when bc--idle-timer (cancel-timer bc--idle-timer))
- (setq bc--idle-timer
- (run-with-idle-timer
- bc-idle-time nil
- (lambda ()
- (when (buffer-live-p buf)
- (with-current-buffer buf
- (setq bc--last-update-tick (buffer-chars-modified-tick))
- (let ((non-essential t)
- (imenu-auto-rescan t))
- (ignore-errors
- (imenu--make-index-alist t))
- (setq bc--ipath-plain-cache nil)
- ;; no point is taxing the mode-line machinery now
- ;; if the buffer isn't showing anywhere.
- (when (get-buffer-window buf t)
- (force-mode-line-update t)))))))))
- imenu--index-alist))
+ ;; Be mindful of indirect buffers (github#31)
+ (let ((buf (or (buffer-base-buffer) (current-buffer))))
+ (with-current-buffer buf
+ (unless (= (buffer-chars-modified-tick) bc--last-update-tick)
+ (setq bc--last-update-tick (buffer-chars-modified-tick))
+ (when bc--idle-timer (cancel-timer bc--idle-timer))
+ (setq bc--idle-timer
+ (run-with-idle-timer
+ bc-idle-time nil
+ (lambda ()
+ (when (buffer-live-p buf)
+ (with-current-buffer buf
+ (setq bc--last-update-tick (buffer-chars-modified-tick))
+ (let ((non-essential t)
+ (imenu-auto-rescan t))
+ (ignore-errors
+ (imenu--make-index-alist t))
+ (setq bc--ipath-plain-cache nil)
+ ;; no point is taxing the mode-line machinery now
+ ;; if the buffer isn't showing anywhere.
+ (when (get-buffer-window buf t)
+ (force-mode-line-update t)))))))))
+ imenu--index-alist)))
;;;; Higher-level functions