* [PATCH v2 0/9] emacs: Unify common key bindings and lots more
@ 2013-09-03 21:45 Austin Clements
2013-09-03 21:45 ` [PATCH v2 1/9] emacs: Consistently use configured sort order Austin Clements
` (11 more replies)
0 siblings, 12 replies; 13+ messages in thread
From: Austin Clements @ 2013-09-03 21:45 UTC (permalink / raw)
To: notmuch
This is v2 of id:1377793557-28878-1-git-send-email-amdragon@mit.edu.
This fixes a problem found by Jani where notmuch-hello would reset
point placement when refreshing in Emacs 24. It also inverts the
sense of notmuch-hello-auto-refresh and makes it a defcustom
(originally I'd intended notmuch-hello-inhibit-auto-refresh for
internal use only, but both Mark and Jani expressed interest in
setting it).
The diff from v1 follows
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 1d6c3a2..55c416a 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -232,6 +232,11 @@ supported for \"Customized queries section\" items."
notmuch-hello-query-section
(function :tag "Custom section"))))
+(defcustom notmuch-hello-auto-refresh t
+ "Automatically refresh when returning to the notmuch-hello buffer."
+ :group 'notmuch-hello
+ :type 'boolean)
+
(defvar notmuch-hello-hidden-sections nil
"List of sections titles whose contents are hidden")
@@ -478,9 +483,6 @@ Such a list can be computed with `notmuch-hello-query-counts'."
;; Lazy - rebuild everything.
(notmuch-hello no-display))
-(defvar notmuch-hello-inhibit-auto-refresh nil
- "Don't refresh notmuch-hello on window configuration changes.")
-
(defun notmuch-hello-window-configuration-change ()
"Hook function to update the hello buffer when it is switched to."
(let ((hello-buf (get-buffer "*notmuch-hello*"))
@@ -501,8 +503,11 @@ Such a list can be computed with `notmuch-hello-query-counts'."
;; is currently visible, was not visible on the last
;; configuration change, and this is not a new window)
(setq do-refresh t)))))
- (when (and do-refresh (not notmuch-hello-inhibit-auto-refresh))
- (notmuch-hello t))
+ (when (and do-refresh notmuch-hello-auto-refresh)
+ ;; Refresh hello as soon as we get back to redisplay. On Emacs
+ ;; 24, we can't do it right here because something in this
+ ;; hook's call stack overrides hello's point placement.
+ (run-at-time nil nil #'notmuch-hello t))
(when (null hello-buf)
;; Clean up hook
(remove-hook 'window-configuration-change-hook
@@ -785,14 +790,15 @@ following:
;; This may cause a window configuration change, so if the
;; auto-refresh hook is already installed, avoid recursive refresh.
- (let ((notmuch-hello-inhibit-auto-refresh t))
+ (let ((notmuch-hello-auto-refresh nil))
(if no-display
(set-buffer "*notmuch-hello*")
(switch-to-buffer "*notmuch-hello*")))
;; Install auto-refresh hook
- (add-hook 'window-configuration-change-hook
- #'notmuch-hello-window-configuration-change)
+ (when notmuch-hello-auto-refresh
+ (add-hook 'window-configuration-change-hook
+ #'notmuch-hello-window-configuration-change))
(let ((target-line (line-number-at-pos))
(target-column (current-column))
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 1/9] emacs: Consistently use configured sort order
2013-09-03 21:45 [PATCH v2 0/9] emacs: Unify common key bindings and lots more Austin Clements
@ 2013-09-03 21:45 ` Austin Clements
2013-09-03 21:45 ` [PATCH v2 2/9] emacs: Refresh hello whenever the user switches to the buffer Austin Clements
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Austin Clements @ 2013-09-03 21:45 UTC (permalink / raw)
To: notmuch
Previously, if `notmuch-search' was called interactively (bound to "s"
in search and show, but not hello), it would always use newest-first.
However, `notmuch-hello-search' (bound to "s" in hello) and
`notmuch-hello-widget-search` would call it with the user-configured
sort order. This inconsistency seems unintentional, so change
`notmuch-search' to use the user-configured sort order when called
interactively.
---
emacs/notmuch.el | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index f3ce840..c964186 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -906,8 +906,18 @@ Other optional parameters are used as follows:
target-thread: A thread ID (without the thread: prefix) that will be made
current if it appears in the search results.
target-line: The line number to move to if the target thread does not
- appear in the search results."
- (interactive)
+ appear in the search results.
+
+When called interactively, this will prompt for a query and use
+the configured default sort order."
+ (interactive
+ (list
+ ;; Prompt for a query
+ nil
+ ;; Use the default search order (if we're doing a search from a
+ ;; search buffer, ignore any buffer-local overrides)
+ (default-value notmuch-search-oldest-first)))
+
(let* ((query (or query (notmuch-read-query "Notmuch search: ")))
(buffer (get-buffer-create (notmuch-search-buffer-title query))))
(switch-to-buffer buffer)
--
1.7.10.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 2/9] emacs: Refresh hello whenever the user switches to the buffer
2013-09-03 21:45 [PATCH v2 0/9] emacs: Unify common key bindings and lots more Austin Clements
2013-09-03 21:45 ` [PATCH v2 1/9] emacs: Consistently use configured sort order Austin Clements
@ 2013-09-03 21:45 ` Austin Clements
2013-09-03 21:45 ` [PATCH v2 3/9] emacs: Bind "s" to notmuch-search in hello-mode Austin Clements
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Austin Clements @ 2013-09-03 21:45 UTC (permalink / raw)
To: notmuch
Previously, we refreshed hello when the user quit a search that was
started from hello. This is fine assuming purely stack-oriented
buffer use, but is quite fragile and requires hacks to search.
This replaces that logic with a new approach that refreshes hello
whenever the user switches to the hello buffer, regardless of how this
happens.
---
emacs/notmuch-hello.el | 58 +++++++++++++++++++++++++++++++++++++++---------
1 file changed, 48 insertions(+), 10 deletions(-)
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 9db8c99..24ac1c6 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -232,6 +232,11 @@ supported for \"Customized queries section\" items."
notmuch-hello-query-section
(function :tag "Custom section"))))
+(defcustom notmuch-hello-auto-refresh t
+ "Automatically refresh when returning to the notmuch-hello buffer."
+ :group 'notmuch-hello
+ :type 'boolean)
+
(defvar notmuch-hello-hidden-sections nil
"List of sections titles whose contents are hidden")
@@ -263,8 +268,7 @@ afterwards.")
(setq search (notmuch-hello-trim search))
(let ((history-delete-duplicates t))
(add-to-history 'notmuch-search-history search)))
- (notmuch-search search notmuch-search-oldest-first nil nil
- #'notmuch-hello-search-continuation))
+ (notmuch-search search notmuch-search-oldest-first))
(defun notmuch-hello-add-saved-search (widget)
(interactive)
@@ -322,8 +326,7 @@ diagonal."
(defun notmuch-hello-widget-search (widget &rest ignore)
(notmuch-search (widget-get widget
:notmuch-search-terms)
- notmuch-search-oldest-first
- nil nil #'notmuch-hello-search-continuation))
+ notmuch-search-oldest-first))
(defun notmuch-saved-search-count (search)
(car (process-lines notmuch-command "count" search)))
@@ -476,9 +479,6 @@ Such a list can be computed with `notmuch-hello-query-counts'."
(defimage notmuch-hello-logo ((:type png :file "notmuch-logo.png")))
-(defun notmuch-hello-search-continuation()
- (notmuch-hello-update t))
-
(defun notmuch-hello-update (&optional no-display)
"Update the current notmuch view."
;; Lazy - rebuild everything.
@@ -491,6 +491,36 @@ Such a list can be computed with `notmuch-hello-query-counts'."
(notmuch-poll)
(notmuch-hello-update))
+(defun notmuch-hello-window-configuration-change ()
+ "Hook function to update the hello buffer when it is switched to."
+ (let ((hello-buf (get-buffer "*notmuch-hello*"))
+ (do-refresh nil))
+ ;; Consider all windows in the currently selected frame, since
+ ;; that's where the configuration change happened. This also
+ ;; refreshes our snapshot of all windows, so we have to do this
+ ;; even if we know we won't refresh (e.g., hello-buf is null).
+ (dolist (window (window-list))
+ (let ((last-buf (window-parameter window 'notmuch-hello-last-buffer))
+ (cur-buf (window-buffer window)))
+ (when (not (eq last-buf cur-buf))
+ ;; This window changed or is new. Update recorded buffer
+ ;; for next time.
+ (set-window-parameter window 'notmuch-hello-last-buffer cur-buf)
+ (when (and (eq cur-buf hello-buf) last-buf)
+ ;; The user just switched to hello in this window (hello
+ ;; is currently visible, was not visible on the last
+ ;; configuration change, and this is not a new window)
+ (setq do-refresh t)))))
+ (when (and do-refresh notmuch-hello-auto-refresh)
+ ;; Refresh hello as soon as we get back to redisplay. On Emacs
+ ;; 24, we can't do it right here because something in this
+ ;; hook's call stack overrides hello's point placement.
+ (run-at-time nil nil #'notmuch-hello t))
+ (when (null hello-buf)
+ ;; Clean up hook
+ (remove-hook 'window-configuration-change-hook
+ #'notmuch-hello-window-configuration-change))))
+
(defvar notmuch-hello-mode-map
(let ((map (make-sparse-keymap)))
@@ -765,9 +795,17 @@ following:
"Run notmuch and display saved searches, known tags, etc."
(interactive)
- (if no-display
- (set-buffer "*notmuch-hello*")
- (switch-to-buffer "*notmuch-hello*"))
+ ;; This may cause a window configuration change, so if the
+ ;; auto-refresh hook is already installed, avoid recursive refresh.
+ (let ((notmuch-hello-auto-refresh nil))
+ (if no-display
+ (set-buffer "*notmuch-hello*")
+ (switch-to-buffer "*notmuch-hello*")))
+
+ ;; Install auto-refresh hook
+ (when notmuch-hello-auto-refresh
+ (add-hook 'window-configuration-change-hook
+ #'notmuch-hello-window-configuration-change))
(let ((target-line (line-number-at-pos))
(target-column (current-column))
--
1.7.10.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 3/9] emacs: Bind "s" to notmuch-search in hello-mode
2013-09-03 21:45 [PATCH v2 0/9] emacs: Unify common key bindings and lots more Austin Clements
2013-09-03 21:45 ` [PATCH v2 1/9] emacs: Consistently use configured sort order Austin Clements
2013-09-03 21:45 ` [PATCH v2 2/9] emacs: Refresh hello whenever the user switches to the buffer Austin Clements
@ 2013-09-03 21:45 ` Austin Clements
2013-09-03 21:45 ` [PATCH v2 4/9] emacs: Remove notmuch-search quit continuation Austin Clements
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Austin Clements @ 2013-09-03 21:45 UTC (permalink / raw)
To: notmuch
Since there is now no difference between notmuch-hello-search and
notmuch-search when called interactively, bind "s" to notmuch-search
in notmuch-hello-mode-map. Now all modes bind "s" this way.
---
emacs/notmuch-hello.el | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 24ac1c6..94cc4b5 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -263,7 +263,6 @@ afterwards.")
search))
(defun notmuch-hello-search (&optional search)
- (interactive)
(unless (null search)
(setq search (notmuch-hello-trim search))
(let ((history-delete-duplicates t))
@@ -533,7 +532,7 @@ Such a list can be computed with `notmuch-hello-query-counts'."
(define-key map "G" 'notmuch-hello-poll-and-update)
(define-key map (kbd "<C-tab>") 'widget-backward)
(define-key map "m" 'notmuch-mua-new-mail)
- (define-key map "s" 'notmuch-hello-search)
+ (define-key map "s" 'notmuch-search)
map)
"Keymap for \"notmuch hello\" buffers.")
(fset 'notmuch-hello-mode-map notmuch-hello-mode-map)
--
1.7.10.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 4/9] emacs: Remove notmuch-search quit continuation
2013-09-03 21:45 [PATCH v2 0/9] emacs: Unify common key bindings and lots more Austin Clements
` (2 preceding siblings ...)
2013-09-03 21:45 ` [PATCH v2 3/9] emacs: Bind "s" to notmuch-search in hello-mode Austin Clements
@ 2013-09-03 21:45 ` Austin Clements
2013-09-03 21:45 ` [PATCH v2 5/9] emacs: Move `notmuch-poll' to notmuch-lib Austin Clements
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Austin Clements @ 2013-09-03 21:45 UTC (permalink / raw)
To: notmuch
Since notmuch-hello doesn't need this any more, we can remove this
hack. This also eliminates `notmuch-search-quit', so now all modes
bind "q" to `notmuch-kill-this-buffer'.
---
emacs/notmuch.el | 22 +++++-----------------
1 file changed, 5 insertions(+), 17 deletions(-)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index c964186..00cf271 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -213,8 +213,8 @@ For a mouse binding, return nil."
(defvar notmuch-search-mode-map
(let ((map (make-sparse-keymap)))
(define-key map "?" 'notmuch-help)
- (define-key map "q" 'notmuch-search-quit)
- (define-key map "x" 'notmuch-search-quit)
+ (define-key map "q" 'notmuch-kill-this-buffer)
+ (define-key map "x" 'notmuch-kill-this-buffer)
(define-key map (kbd "<DEL>") 'notmuch-search-scroll-down)
(define-key map "b" 'notmuch-search-scroll-down)
(define-key map " " 'notmuch-search-scroll-up)
@@ -257,18 +257,9 @@ For a mouse binding, return nil."
(defvar notmuch-search-query-string)
(defvar notmuch-search-target-thread)
(defvar notmuch-search-target-line)
-(defvar notmuch-search-continuation)
(defvar notmuch-search-disjunctive-regexp "\\<[oO][rR]\\>")
-(defun notmuch-search-quit ()
- "Exit the search buffer, calling any defined continuation function."
- (interactive)
- (let ((continuation notmuch-search-continuation))
- (notmuch-kill-this-buffer)
- (when continuation
- (funcall continuation))))
-
(defun notmuch-search-scroll-up ()
"Move forward through search results by one window's worth."
(interactive)
@@ -412,7 +403,6 @@ Complete list of currently available key bindings:
(make-local-variable 'notmuch-search-oldest-first)
(make-local-variable 'notmuch-search-target-thread)
(make-local-variable 'notmuch-search-target-line)
- (set (make-local-variable 'notmuch-search-continuation) nil)
(set (make-local-variable 'scroll-preserve-screen-position) t)
(add-to-invisibility-spec (cons 'ellipsis t))
(use-local-map notmuch-search-mode-map)
@@ -896,7 +886,7 @@ PROMPT is the string to prompt with."
'notmuch-search-history nil nil)))))
;;;###autoload
-(defun notmuch-search (&optional query oldest-first target-thread target-line continuation)
+(defun notmuch-search (&optional query oldest-first target-thread target-line)
"Run \"notmuch search\" with the given `query' and display results.
If `query' is nil, it is read interactively from the minibuffer.
@@ -928,7 +918,6 @@ the configured default sort order."
(set 'notmuch-search-oldest-first oldest-first)
(set 'notmuch-search-target-thread target-thread)
(set 'notmuch-search-target-line target-line)
- (set 'notmuch-search-continuation continuation)
(let ((proc (get-buffer-process (current-buffer)))
(inhibit-read-only t))
(if proc
@@ -965,10 +954,9 @@ same relative position within the new buffer."
(let ((target-line (line-number-at-pos))
(oldest-first notmuch-search-oldest-first)
(target-thread (notmuch-search-find-thread-id 'bare))
- (query notmuch-search-query-string)
- (continuation notmuch-search-continuation))
+ (query notmuch-search-query-string))
(notmuch-kill-this-buffer)
- (notmuch-search query oldest-first target-thread target-line continuation)
+ (notmuch-search query oldest-first target-thread target-line)
(goto-char (point-min))))
(defcustom notmuch-poll-script nil
--
1.7.10.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 5/9] emacs: Move `notmuch-poll' to notmuch-lib
2013-09-03 21:45 [PATCH v2 0/9] emacs: Unify common key bindings and lots more Austin Clements
` (3 preceding siblings ...)
2013-09-03 21:45 ` [PATCH v2 4/9] emacs: Remove notmuch-search quit continuation Austin Clements
@ 2013-09-03 21:45 ` Austin Clements
2013-09-03 21:45 ` [PATCH v2 6/9] emacs: Add unified refresh-this-buffer function Austin Clements
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Austin Clements @ 2013-09-03 21:45 UTC (permalink / raw)
To: notmuch
---
emacs/notmuch-lib.el | 38 ++++++++++++++++++++++++++++++++++++++
emacs/notmuch.el | 38 --------------------------------------
2 files changed, 38 insertions(+), 38 deletions(-)
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 4796f17..9754e16 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -76,6 +76,33 @@ search."
:type 'boolean
:group 'notmuch-search)
+(defcustom notmuch-poll-script nil
+ "An external script to incorporate new mail into the notmuch database.
+
+This variable controls the action invoked by
+`notmuch-search-poll-and-refresh-view' and
+`notmuch-hello-poll-and-update' (each have a default keybinding
+of 'G') to incorporate new mail into the notmuch database.
+
+If set to nil (the default), new mail is processed by invoking
+\"notmuch new\". Otherwise, this should be set to a string that
+gives the name of an external script that processes new mail. If
+set to the empty string, no command will be run.
+
+The external script could do any of the following depending on
+the user's needs:
+
+1. Invoke a program to transfer mail to the local mail store
+2. Invoke \"notmuch new\" to incorporate the new mail
+3. Invoke one or more \"notmuch tag\" commands to classify the mail
+
+Note that the recommended way of achieving the same is using
+\"notmuch new\" hooks."
+ :type '(choice (const :tag "notmuch new" nil)
+ (const :tag "Disabled" "")
+ (string :tag "Custom script"))
+ :group 'notmuch-external)
+
;;
(defvar notmuch-search-history nil
@@ -161,6 +188,17 @@ Otherwise the output will be returned"
"Return the user.other_email value (as a list) from the notmuch configuration."
(split-string (notmuch-config-get "user.other_email") "\n"))
+(defun notmuch-poll ()
+ "Run \"notmuch new\" or an external script to import mail.
+
+Invokes `notmuch-poll-script', \"notmuch new\", or does nothing
+depending on the value of `notmuch-poll-script'."
+ (interactive)
+ (if (stringp notmuch-poll-script)
+ (unless (string= notmuch-poll-script "")
+ (call-process notmuch-poll-script nil nil))
+ (call-process notmuch-command nil nil nil "new")))
+
(defun notmuch-kill-this-buffer ()
"Kill the current buffer."
(interactive)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 00cf271..82cece8 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -959,44 +959,6 @@ same relative position within the new buffer."
(notmuch-search query oldest-first target-thread target-line)
(goto-char (point-min))))
-(defcustom notmuch-poll-script nil
- "An external script to incorporate new mail into the notmuch database.
-
-This variable controls the action invoked by
-`notmuch-search-poll-and-refresh-view' and
-`notmuch-hello-poll-and-update' (each have a default keybinding
-of 'G') to incorporate new mail into the notmuch database.
-
-If set to nil (the default), new mail is processed by invoking
-\"notmuch new\". Otherwise, this should be set to a string that
-gives the name of an external script that processes new mail. If
-set to the empty string, no command will be run.
-
-The external script could do any of the following depending on
-the user's needs:
-
-1. Invoke a program to transfer mail to the local mail store
-2. Invoke \"notmuch new\" to incorporate the new mail
-3. Invoke one or more \"notmuch tag\" commands to classify the mail
-
-Note that the recommended way of achieving the same is using
-\"notmuch new\" hooks."
- :type '(choice (const :tag "notmuch new" nil)
- (const :tag "Disabled" "")
- (string :tag "Custom script"))
- :group 'notmuch-external)
-
-(defun notmuch-poll ()
- "Run \"notmuch new\" or an external script to import mail.
-
-Invokes `notmuch-poll-script', \"notmuch new\", or does nothing
-depending on the value of `notmuch-poll-script'."
- (interactive)
- (if (stringp notmuch-poll-script)
- (unless (string= notmuch-poll-script "")
- (call-process notmuch-poll-script nil nil))
- (call-process notmuch-command nil nil nil "new")))
-
(defun notmuch-search-poll-and-refresh-view ()
"Invoke `notmuch-poll' to import mail, then refresh the current view."
(interactive)
--
1.7.10.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 6/9] emacs: Add unified refresh-this-buffer function
2013-09-03 21:45 [PATCH v2 0/9] emacs: Unify common key bindings and lots more Austin Clements
` (4 preceding siblings ...)
2013-09-03 21:45 ` [PATCH v2 5/9] emacs: Move `notmuch-poll' to notmuch-lib Austin Clements
@ 2013-09-03 21:45 ` Austin Clements
2013-09-03 21:45 ` [PATCH v2 7/9] emacs: Make notmuch-help work with arbitrary keymaps Austin Clements
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Austin Clements @ 2013-09-03 21:45 UTC (permalink / raw)
To: notmuch
This unifies the various refresh and poll-and-refresh functions we
have for different modes. Now all modes bind "=" and "G" (except
show, which doesn't bind "G" for some reason) to
`notmuch-refresh-this-buffer' and
`notmuch-poll-and-refresh-this-buffer', respectively.
---
emacs/notmuch-hello.el | 12 +++---------
emacs/notmuch-lib.el | 20 +++++++++++++++++++-
emacs/notmuch-show.el | 3 ++-
emacs/notmuch.el | 12 +++---------
4 files changed, 27 insertions(+), 20 deletions(-)
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 94cc4b5..6a7b884 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -481,15 +481,8 @@ Such a list can be computed with `notmuch-hello-query-counts'."
(defun notmuch-hello-update (&optional no-display)
"Update the current notmuch view."
;; Lazy - rebuild everything.
- (interactive)
(notmuch-hello no-display))
-(defun notmuch-hello-poll-and-update ()
- "Invoke `notmuch-poll' to import mail, then refresh the current view."
- (interactive)
- (notmuch-poll)
- (notmuch-hello-update))
-
(defun notmuch-hello-window-configuration-change ()
"Hook function to update the hello buffer when it is switched to."
(let ((hello-buf (get-buffer "*notmuch-hello*"))
@@ -528,8 +521,8 @@ Such a list can be computed with `notmuch-hello-query-counts'."
(message "notmuch version %s" (notmuch-version))))
(define-key map "?" 'notmuch-help)
(define-key map "q" 'notmuch-kill-this-buffer)
- (define-key map "=" 'notmuch-hello-update)
- (define-key map "G" 'notmuch-hello-poll-and-update)
+ (define-key map "=" 'notmuch-refresh-this-buffer)
+ (define-key map "G" 'notmuch-poll-and-refresh-this-buffer)
(define-key map (kbd "<C-tab>") 'widget-backward)
(define-key map "m" 'notmuch-mua-new-mail)
(define-key map "s" 'notmuch-search)
@@ -545,6 +538,7 @@ Complete list of currently available key bindings:
\\{notmuch-hello-mode-map}"
(interactive)
(kill-all-local-variables)
+ (setq notmuch-buffer-refresh-function #'notmuch-hello-update)
(use-local-map notmuch-hello-mode-map)
(setq major-mode 'notmuch-hello-mode
mode-name "notmuch-hello")
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 9754e16..782badb 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -204,6 +204,25 @@ depending on the value of `notmuch-poll-script'."
(interactive)
(kill-buffer (current-buffer)))
+(defvar notmuch-buffer-refresh-function nil
+ "Function to call to refresh the current buffer.")
+(make-variable-buffer-local 'notmuch-buffer-refresh-function)
+
+(defun notmuch-refresh-this-buffer ()
+ "Refresh the current buffer."
+ (interactive)
+ (when notmuch-buffer-refresh-function
+ (if (commandp notmuch-buffer-refresh-function)
+ ;; Pass prefix argument, etc.
+ (call-interactively notmuch-buffer-refresh-function)
+ (funcall notmuch-buffer-refresh-function))))
+
+(defun notmuch-poll-and-refresh-this-buffer ()
+ "Invoke `notmuch-poll' to import mail, then refresh the current buffer."
+ (interactive)
+ (notmuch-poll)
+ (notmuch-refresh-this-buffer))
+
(defun notmuch-prettify-subject (subject)
;; This function is used by `notmuch-search-process-filter' which
;; requires that we not disrupt its' matching state.
@@ -596,7 +615,6 @@ status."
(defvar notmuch-show-process-crypto nil)
(make-variable-buffer-local 'notmuch-show-process-crypto)
-
(provide 'notmuch-lib)
;; Local Variables:
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 82b70ba..380df66 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1279,7 +1279,7 @@ reset based on the original query."
(define-key map "w" 'notmuch-show-save-attachments)
(define-key map "V" 'notmuch-show-view-raw-message)
(define-key map "c" 'notmuch-show-stash-map)
- (define-key map "=" 'notmuch-show-refresh-view)
+ (define-key map "=" 'notmuch-refresh-this-buffer)
(define-key map "h" 'notmuch-show-toggle-visibility-headers)
(define-key map "*" 'notmuch-show-tag-all)
(define-key map "-" 'notmuch-show-remove-tag)
@@ -1338,6 +1338,7 @@ All currently available key bindings:
\\{notmuch-show-mode-map}"
(interactive)
(kill-all-local-variables)
+ (setq notmuch-buffer-refresh-function #'notmuch-show-refresh-view)
(use-local-map notmuch-show-mode-map)
(setq major-mode 'notmuch-show-mode
mode-name "notmuch-show")
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 82cece8..80446be 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -228,8 +228,8 @@ For a mouse binding, return nil."
(define-key map "s" 'notmuch-search)
(define-key map "o" 'notmuch-search-toggle-order)
(define-key map "c" 'notmuch-search-stash-map)
- (define-key map "=" 'notmuch-search-refresh-view)
- (define-key map "G" 'notmuch-search-poll-and-refresh-view)
+ (define-key map "=" 'notmuch-refresh-this-buffer)
+ (define-key map "G" 'notmuch-poll-and-refresh-this-buffer)
(define-key map "t" 'notmuch-search-filter-by-tag)
(define-key map "f" 'notmuch-search-filter)
(define-key map [mouse-1] 'notmuch-search-show-thread)
@@ -403,6 +403,7 @@ Complete list of currently available key bindings:
(make-local-variable 'notmuch-search-oldest-first)
(make-local-variable 'notmuch-search-target-thread)
(make-local-variable 'notmuch-search-target-line)
+ (setq notmuch-buffer-refresh-function #'notmuch-search-refresh-view)
(set (make-local-variable 'scroll-preserve-screen-position) t)
(add-to-invisibility-spec (cons 'ellipsis t))
(use-local-map notmuch-search-mode-map)
@@ -950,7 +951,6 @@ query string as the current search. If the current thread is in
the new search results, then point will be placed on the same
thread. Otherwise, point will be moved to attempt to be in the
same relative position within the new buffer."
- (interactive)
(let ((target-line (line-number-at-pos))
(oldest-first notmuch-search-oldest-first)
(target-thread (notmuch-search-find-thread-id 'bare))
@@ -959,12 +959,6 @@ same relative position within the new buffer."
(notmuch-search query oldest-first target-thread target-line)
(goto-char (point-min))))
-(defun notmuch-search-poll-and-refresh-view ()
- "Invoke `notmuch-poll' to import mail, then refresh the current view."
- (interactive)
- (notmuch-poll)
- (notmuch-search-refresh-view))
-
(defun notmuch-search-toggle-order ()
"Toggle the current search order.
--
1.7.10.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 7/9] emacs: Make notmuch-help work with arbitrary keymaps
2013-09-03 21:45 [PATCH v2 0/9] emacs: Unify common key bindings and lots more Austin Clements
` (5 preceding siblings ...)
2013-09-03 21:45 ` [PATCH v2 6/9] emacs: Add unified refresh-this-buffer function Austin Clements
@ 2013-09-03 21:45 ` Austin Clements
2013-09-03 21:45 ` [PATCH v2 8/9] emacs: Define a common shared keymap for all of notmuch Austin Clements
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Austin Clements @ 2013-09-03 21:45 UTC (permalink / raw)
To: notmuch
This converts notmuch-help to use map-keymap for all keymap traversal.
This generally cleans up and simplifies construction of keymap
documentation, and also makes notmuch-help support anything that can
be in a keymap, including more esoteric stuff like multiple
inheritance.
---
emacs/notmuch.el | 58 +++++++++++++++++++++---------------------------------
1 file changed, 22 insertions(+), 36 deletions(-)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 80446be..0304096 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -140,48 +140,34 @@ This is basically just `format-kbd-macro' but we also convert ESC to M-."
"M-"
(concat desc " "))))
-;; I would think that emacs would have code handy for walking a keymap
-;; and generating strings for each key, and I would prefer to just call
-;; that. But I couldn't find any (could be all implemented in C I
-;; suppose), so I wrote my own here.
-(defun notmuch-substitute-one-command-key-with-prefix (prefix binding)
- "For a key binding, return a string showing a human-readable
-representation of the prefixed key as well as the first line of
-documentation from the bound function.
-
-For a mouse binding, return nil."
- (let ((key (car binding))
- (action (cdr binding)))
- (if (mouse-event-p key)
- nil
- (if (keymapp action)
- (let ((substitute (apply-partially 'notmuch-substitute-one-command-key-with-prefix (notmuch-prefix-key-description key)))
- (as-list))
- (map-keymap (lambda (a b)
- (push (cons a b) as-list))
- action)
- (mapconcat substitute as-list "\n"))
- (concat prefix (format-kbd-macro (vector key))
- "\t"
- (notmuch-documentation-first-line action))))))
-
-(defun notmuch-substitute-command-keys-one (key)
- ;; A `keymap' key indicates inheritance from a parent keymap - the
- ;; inherited mappings follow, so there is nothing to print for
- ;; `keymap' itself.
- (when (not (eq key 'keymap))
- (notmuch-substitute-one-command-key-with-prefix nil key)))
+(defun notmuch-describe-keymap (keymap &optional prefix tail)
+ "Return a list of strings, each describing one key in KEYMAP.
+
+Each string gives a human-readable description of the key and the
+first line of documentation for the bound function."
+ (map-keymap
+ (lambda (key binding)
+ (cond ((mouse-event-p key) nil)
+ ((keymapp binding)
+ (setq tail
+ (notmuch-describe-keymap
+ binding (notmuch-prefix-key-description key) tail)))
+ (t
+ (push (concat prefix (format-kbd-macro (vector key)) "\t"
+ (notmuch-documentation-first-line binding))
+ tail))))
+ keymap)
+ tail)
(defun notmuch-substitute-command-keys (doc)
"Like `substitute-command-keys' but with documentation, not function names."
(let ((beg 0))
(while (string-match "\\\\{\\([^}[:space:]]*\\)}" doc beg)
(let* ((keymap-name (substring doc (match-beginning 1) (match-end 1)))
- (keymap (symbol-value (intern keymap-name))))
- (setq doc (replace-match
- (mapconcat #'notmuch-substitute-command-keys-one
- (cdr keymap) "\n")
- 1 1 doc)))
+ (keymap (symbol-value (intern keymap-name)))
+ (desc-list (notmuch-describe-keymap keymap))
+ (desc (mapconcat #'identity desc-list "\n")))
+ (setq doc (replace-match desc 1 1 doc)))
(setq beg (match-end 0)))
doc))
--
1.7.10.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 8/9] emacs: Define a common shared keymap for all of notmuch
2013-09-03 21:45 [PATCH v2 0/9] emacs: Unify common key bindings and lots more Austin Clements
` (6 preceding siblings ...)
2013-09-03 21:45 ` [PATCH v2 7/9] emacs: Make notmuch-help work with arbitrary keymaps Austin Clements
@ 2013-09-03 21:45 ` Austin Clements
2013-09-03 21:45 ` [PATCH v2 9/9] emacs: Move ?, q, s, m, =, and G to the common keymap Austin Clements
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Austin Clements @ 2013-09-03 21:45 UTC (permalink / raw)
To: notmuch
This defines a single, currently empty keymap that all other notmuch
mode maps inherit from.
---
emacs/notmuch-hello.el | 10 ++++++++--
emacs/notmuch-lib.el | 5 +++++
emacs/notmuch-show.el | 1 +
emacs/notmuch.el | 1 +
4 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 6a7b884..46baf55 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -515,8 +515,14 @@ Such a list can be computed with `notmuch-hello-query-counts'."
(defvar notmuch-hello-mode-map
- (let ((map (make-sparse-keymap)))
- (set-keymap-parent map widget-keymap)
+ (let ((map (if (fboundp 'make-composed-keymap)
+ ;; Inherit both widget-keymap and notmuch-common-keymap
+ (make-composed-keymap widget-keymap)
+ ;; Before Emacs 24, keymaps didn't support multiple
+ ;; inheritance,, so just copy the widget keymap since
+ ;; it's unlikely to change.
+ (copy-keymap widget-keymap))))
+ (set-keymap-parent map notmuch-common-keymap)
(define-key map "v" (lambda () "Display the notmuch version" (interactive)
(message "notmuch version %s" (notmuch-version))))
(define-key map "?" 'notmuch-help)
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 782badb..2bf1d2f 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -128,6 +128,11 @@ For example, if you wanted to remove an \"inbox\" tag and add an
:group 'notmuch-search
:group 'notmuch-show)
+(defvar notmuch-common-keymap
+ (let ((map (make-sparse-keymap)))
+ map)
+ "Keymap shared by all notmuch modes.")
+
;; By default clicking on a button does not select the window
;; containing the button (as opposed to clicking on a widget which
;; does). This means that the button action is then executed in the
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 380df66..9f67340 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1264,6 +1264,7 @@ reset based on the original query."
(defvar notmuch-show-mode-map
(let ((map (make-sparse-keymap)))
+ (set-keymap-parent map notmuch-common-keymap)
(define-key map "?" 'notmuch-help)
(define-key map "q" 'notmuch-kill-this-buffer)
(define-key map (kbd "<C-tab>") 'widget-backward)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 0304096..e098bd7 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -198,6 +198,7 @@ first line of documentation for the bound function."
(defvar notmuch-search-mode-map
(let ((map (make-sparse-keymap)))
+ (set-keymap-parent map notmuch-common-keymap)
(define-key map "?" 'notmuch-help)
(define-key map "q" 'notmuch-kill-this-buffer)
(define-key map "x" 'notmuch-kill-this-buffer)
--
1.7.10.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 9/9] emacs: Move ?, q, s, m, =, and G to the common keymap
2013-09-03 21:45 [PATCH v2 0/9] emacs: Unify common key bindings and lots more Austin Clements
` (7 preceding siblings ...)
2013-09-03 21:45 ` [PATCH v2 8/9] emacs: Define a common shared keymap for all of notmuch Austin Clements
@ 2013-09-03 21:45 ` Austin Clements
2013-09-05 9:27 ` [PATCH v2 0/9] emacs: Unify common key bindings and lots more Mark Walters
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Austin Clements @ 2013-09-03 21:45 UTC (permalink / raw)
To: notmuch
The only user-visible effect of this should be that "G" now works in
show mode (previously it was unbound for no apparent reason).
This shared keymap gives us one place to put global commands, which
both forces us to think about what commands should be global, and
ensures their bindings can't diverge (like the missing "G" in show).
---
emacs/notmuch-hello.el | 6 ------
emacs/notmuch-lib.el | 6 ++++++
emacs/notmuch-show.el | 5 -----
emacs/notmuch.el | 6 ------
4 files changed, 6 insertions(+), 17 deletions(-)
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 46baf55..55c416a 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -525,13 +525,7 @@ Such a list can be computed with `notmuch-hello-query-counts'."
(set-keymap-parent map notmuch-common-keymap)
(define-key map "v" (lambda () "Display the notmuch version" (interactive)
(message "notmuch version %s" (notmuch-version))))
- (define-key map "?" 'notmuch-help)
- (define-key map "q" 'notmuch-kill-this-buffer)
- (define-key map "=" 'notmuch-refresh-this-buffer)
- (define-key map "G" 'notmuch-poll-and-refresh-this-buffer)
(define-key map (kbd "<C-tab>") 'widget-backward)
- (define-key map "m" 'notmuch-mua-new-mail)
- (define-key map "s" 'notmuch-search)
map)
"Keymap for \"notmuch hello\" buffers.")
(fset 'notmuch-hello-mode-map notmuch-hello-mode-map)
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 2bf1d2f..58f3313 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -130,6 +130,12 @@ For example, if you wanted to remove an \"inbox\" tag and add an
(defvar notmuch-common-keymap
(let ((map (make-sparse-keymap)))
+ (define-key map "?" 'notmuch-help)
+ (define-key map "q" 'notmuch-kill-this-buffer)
+ (define-key map "s" 'notmuch-search)
+ (define-key map "m" 'notmuch-mua-new-mail)
+ (define-key map "=" 'notmuch-refresh-this-buffer)
+ (define-key map "G" 'notmuch-poll-and-refresh-this-buffer)
map)
"Keymap shared by all notmuch modes.")
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 9f67340..9d8b785 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1265,14 +1265,10 @@ reset based on the original query."
(defvar notmuch-show-mode-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map notmuch-common-keymap)
- (define-key map "?" 'notmuch-help)
- (define-key map "q" 'notmuch-kill-this-buffer)
(define-key map (kbd "<C-tab>") 'widget-backward)
(define-key map (kbd "M-TAB") 'notmuch-show-previous-button)
(define-key map (kbd "<backtab>") 'notmuch-show-previous-button)
(define-key map (kbd "TAB") 'notmuch-show-next-button)
- (define-key map "s" 'notmuch-search)
- (define-key map "m" 'notmuch-mua-new-mail)
(define-key map "f" 'notmuch-show-forward-message)
(define-key map "r" 'notmuch-show-reply-sender)
(define-key map "R" 'notmuch-show-reply)
@@ -1280,7 +1276,6 @@ reset based on the original query."
(define-key map "w" 'notmuch-show-save-attachments)
(define-key map "V" 'notmuch-show-view-raw-message)
(define-key map "c" 'notmuch-show-stash-map)
- (define-key map "=" 'notmuch-refresh-this-buffer)
(define-key map "h" 'notmuch-show-toggle-visibility-headers)
(define-key map "*" 'notmuch-show-tag-all)
(define-key map "-" 'notmuch-show-remove-tag)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index e098bd7..4de6229 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -199,8 +199,6 @@ first line of documentation for the bound function."
(defvar notmuch-search-mode-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map notmuch-common-keymap)
- (define-key map "?" 'notmuch-help)
- (define-key map "q" 'notmuch-kill-this-buffer)
(define-key map "x" 'notmuch-kill-this-buffer)
(define-key map (kbd "<DEL>") 'notmuch-search-scroll-down)
(define-key map "b" 'notmuch-search-scroll-down)
@@ -211,12 +209,8 @@ first line of documentation for the bound function."
(define-key map "n" 'notmuch-search-next-thread)
(define-key map "r" 'notmuch-search-reply-to-thread-sender)
(define-key map "R" 'notmuch-search-reply-to-thread)
- (define-key map "m" 'notmuch-mua-new-mail)
- (define-key map "s" 'notmuch-search)
(define-key map "o" 'notmuch-search-toggle-order)
(define-key map "c" 'notmuch-search-stash-map)
- (define-key map "=" 'notmuch-refresh-this-buffer)
- (define-key map "G" 'notmuch-poll-and-refresh-this-buffer)
(define-key map "t" 'notmuch-search-filter-by-tag)
(define-key map "f" 'notmuch-search-filter)
(define-key map [mouse-1] 'notmuch-search-show-thread)
--
1.7.10.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v2 0/9] emacs: Unify common key bindings and lots more
2013-09-03 21:45 [PATCH v2 0/9] emacs: Unify common key bindings and lots more Austin Clements
` (8 preceding siblings ...)
2013-09-03 21:45 ` [PATCH v2 9/9] emacs: Move ?, q, s, m, =, and G to the common keymap Austin Clements
@ 2013-09-05 9:27 ` Mark Walters
2013-09-09 16:59 ` Tomi Ollila
2013-09-10 11:15 ` David Bremner
11 siblings, 0 replies; 13+ messages in thread
From: Mark Walters @ 2013-09-05 9:27 UTC (permalink / raw)
To: Austin Clements, notmuch
LGTM +1. (The defcustom is a nice addition)
Mark
On Tue, 03 Sep 2013, Austin Clements <amdragon@MIT.EDU> wrote:
> This is v2 of id:1377793557-28878-1-git-send-email-amdragon@mit.edu.
> This fixes a problem found by Jani where notmuch-hello would reset
> point placement when refreshing in Emacs 24. It also inverts the
> sense of notmuch-hello-auto-refresh and makes it a defcustom
> (originally I'd intended notmuch-hello-inhibit-auto-refresh for
> internal use only, but both Mark and Jani expressed interest in
> setting it).
>
> The diff from v1 follows
>
> diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
> index 1d6c3a2..55c416a 100644
> --- a/emacs/notmuch-hello.el
> +++ b/emacs/notmuch-hello.el
> @@ -232,6 +232,11 @@ supported for \"Customized queries section\" items."
> notmuch-hello-query-section
> (function :tag "Custom section"))))
>
> +(defcustom notmuch-hello-auto-refresh t
> + "Automatically refresh when returning to the notmuch-hello buffer."
> + :group 'notmuch-hello
> + :type 'boolean)
> +
> (defvar notmuch-hello-hidden-sections nil
> "List of sections titles whose contents are hidden")
>
> @@ -478,9 +483,6 @@ Such a list can be computed with `notmuch-hello-query-counts'."
> ;; Lazy - rebuild everything.
> (notmuch-hello no-display))
>
> -(defvar notmuch-hello-inhibit-auto-refresh nil
> - "Don't refresh notmuch-hello on window configuration changes.")
> -
> (defun notmuch-hello-window-configuration-change ()
> "Hook function to update the hello buffer when it is switched to."
> (let ((hello-buf (get-buffer "*notmuch-hello*"))
> @@ -501,8 +503,11 @@ Such a list can be computed with `notmuch-hello-query-counts'."
> ;; is currently visible, was not visible on the last
> ;; configuration change, and this is not a new window)
> (setq do-refresh t)))))
> - (when (and do-refresh (not notmuch-hello-inhibit-auto-refresh))
> - (notmuch-hello t))
> + (when (and do-refresh notmuch-hello-auto-refresh)
> + ;; Refresh hello as soon as we get back to redisplay. On Emacs
> + ;; 24, we can't do it right here because something in this
> + ;; hook's call stack overrides hello's point placement.
> + (run-at-time nil nil #'notmuch-hello t))
> (when (null hello-buf)
> ;; Clean up hook
> (remove-hook 'window-configuration-change-hook
> @@ -785,14 +790,15 @@ following:
>
> ;; This may cause a window configuration change, so if the
> ;; auto-refresh hook is already installed, avoid recursive refresh.
> - (let ((notmuch-hello-inhibit-auto-refresh t))
> + (let ((notmuch-hello-auto-refresh nil))
> (if no-display
> (set-buffer "*notmuch-hello*")
> (switch-to-buffer "*notmuch-hello*")))
>
> ;; Install auto-refresh hook
> - (add-hook 'window-configuration-change-hook
> - #'notmuch-hello-window-configuration-change)
> + (when notmuch-hello-auto-refresh
> + (add-hook 'window-configuration-change-hook
> + #'notmuch-hello-window-configuration-change))
>
> (let ((target-line (line-number-at-pos))
> (target-column (current-column))
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 0/9] emacs: Unify common key bindings and lots more
2013-09-03 21:45 [PATCH v2 0/9] emacs: Unify common key bindings and lots more Austin Clements
` (9 preceding siblings ...)
2013-09-05 9:27 ` [PATCH v2 0/9] emacs: Unify common key bindings and lots more Mark Walters
@ 2013-09-09 16:59 ` Tomi Ollila
2013-09-10 11:15 ` David Bremner
11 siblings, 0 replies; 13+ messages in thread
From: Tomi Ollila @ 2013-09-09 16:59 UTC (permalink / raw)
To: Austin Clements, notmuch
On Wed, Sep 04 2013, Austin Clements <amdragon@MIT.EDU> wrote:
> This is v2 of id:1377793557-28878-1-git-send-email-amdragon@mit.edu.
> This fixes a problem found by Jani where notmuch-hello would reset
> point placement when refreshing in Emacs 24. It also inverts the
> sense of notmuch-hello-auto-refresh and makes it a defcustom
> (originally I'd intended notmuch-hello-inhibit-auto-refresh for
> internal use only, but both Mark and Jani expressed interest in
> setting it).
I've been using this patch series a few days now it has worked fine.
It took me a while to grok the notmuch-hello-window-configuration-change
which imo provides nice piece of functionality.
The whole patch series LGTM.
Tomi
>
> The diff from v1 follows
>
> diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
> index 1d6c3a2..55c416a 100644
> --- a/emacs/notmuch-hello.el
> +++ b/emacs/notmuch-hello.el
> @@ -232,6 +232,11 @@ supported for \"Customized queries section\" items."
> notmuch-hello-query-section
> (function :tag "Custom section"))))
>
> +(defcustom notmuch-hello-auto-refresh t
> + "Automatically refresh when returning to the notmuch-hello buffer."
> + :group 'notmuch-hello
> + :type 'boolean)
> +
> (defvar notmuch-hello-hidden-sections nil
> "List of sections titles whose contents are hidden")
>
> @@ -478,9 +483,6 @@ Such a list can be computed with `notmuch-hello-query-counts'."
> ;; Lazy - rebuild everything.
> (notmuch-hello no-display))
>
> -(defvar notmuch-hello-inhibit-auto-refresh nil
> - "Don't refresh notmuch-hello on window configuration changes.")
> -
> (defun notmuch-hello-window-configuration-change ()
> "Hook function to update the hello buffer when it is switched to."
> (let ((hello-buf (get-buffer "*notmuch-hello*"))
> @@ -501,8 +503,11 @@ Such a list can be computed with `notmuch-hello-query-counts'."
> ;; is currently visible, was not visible on the last
> ;; configuration change, and this is not a new window)
> (setq do-refresh t)))))
> - (when (and do-refresh (not notmuch-hello-inhibit-auto-refresh))
> - (notmuch-hello t))
> + (when (and do-refresh notmuch-hello-auto-refresh)
> + ;; Refresh hello as soon as we get back to redisplay. On Emacs
> + ;; 24, we can't do it right here because something in this
> + ;; hook's call stack overrides hello's point placement.
> + (run-at-time nil nil #'notmuch-hello t))
> (when (null hello-buf)
> ;; Clean up hook
> (remove-hook 'window-configuration-change-hook
> @@ -785,14 +790,15 @@ following:
>
> ;; This may cause a window configuration change, so if the
> ;; auto-refresh hook is already installed, avoid recursive refresh.
> - (let ((notmuch-hello-inhibit-auto-refresh t))
> + (let ((notmuch-hello-auto-refresh nil))
> (if no-display
> (set-buffer "*notmuch-hello*")
> (switch-to-buffer "*notmuch-hello*")))
>
> ;; Install auto-refresh hook
> - (add-hook 'window-configuration-change-hook
> - #'notmuch-hello-window-configuration-change)
> + (when notmuch-hello-auto-refresh
> + (add-hook 'window-configuration-change-hook
> + #'notmuch-hello-window-configuration-change))
>
> (let ((target-line (line-number-at-pos))
> (target-column (current-column))
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
>
--
"kaik on mänt!"
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 0/9] emacs: Unify common key bindings and lots more
2013-09-03 21:45 [PATCH v2 0/9] emacs: Unify common key bindings and lots more Austin Clements
` (10 preceding siblings ...)
2013-09-09 16:59 ` Tomi Ollila
@ 2013-09-10 11:15 ` David Bremner
11 siblings, 0 replies; 13+ messages in thread
From: David Bremner @ 2013-09-10 11:15 UTC (permalink / raw)
To: Austin Clements, notmuch
Austin Clements <amdragon@MIT.EDU> writes:
> This is v2 of id:1377793557-28878-1-git-send-email-amdragon@mit.edu.
> This fixes a problem found by Jani where notmuch-hello would reset
> point placement when refreshing in Emacs 24. It also inverts the
> sense of notmuch-hello-auto-refresh and makes it a defcustom
> (originally I'd intended notmuch-hello-inhibit-auto-refresh for
> internal use only, but both Mark and Jani expressed interest in
> setting it).
pushed,
d
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2013-09-10 11:15 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-03 21:45 [PATCH v2 0/9] emacs: Unify common key bindings and lots more Austin Clements
2013-09-03 21:45 ` [PATCH v2 1/9] emacs: Consistently use configured sort order Austin Clements
2013-09-03 21:45 ` [PATCH v2 2/9] emacs: Refresh hello whenever the user switches to the buffer Austin Clements
2013-09-03 21:45 ` [PATCH v2 3/9] emacs: Bind "s" to notmuch-search in hello-mode Austin Clements
2013-09-03 21:45 ` [PATCH v2 4/9] emacs: Remove notmuch-search quit continuation Austin Clements
2013-09-03 21:45 ` [PATCH v2 5/9] emacs: Move `notmuch-poll' to notmuch-lib Austin Clements
2013-09-03 21:45 ` [PATCH v2 6/9] emacs: Add unified refresh-this-buffer function Austin Clements
2013-09-03 21:45 ` [PATCH v2 7/9] emacs: Make notmuch-help work with arbitrary keymaps Austin Clements
2013-09-03 21:45 ` [PATCH v2 8/9] emacs: Define a common shared keymap for all of notmuch Austin Clements
2013-09-03 21:45 ` [PATCH v2 9/9] emacs: Move ?, q, s, m, =, and G to the common keymap Austin Clements
2013-09-05 9:27 ` [PATCH v2 0/9] emacs: Unify common key bindings and lots more Mark Walters
2013-09-09 16:59 ` Tomi Ollila
2013-09-10 11:15 ` David Bremner
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).