mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-21 18:38:08 +01:00
Fix bug in adding or removing tag by region.
There was a bug in notmuch-search-{add,remove}-tag-region, which would not behave correctly if the region went beyond the last message. Now, instead of simply iterating to the last line of the region, these functions will iterate to the minimum of the last line of the region and the last possible line, i.e. (- (line-number-at-pos (point-max)) 2) Tested-by: Carl Worth <cworth@cworth.org> Note that the old, buggy behavior included infinite loops of emacs lisp code, so the new behavior is significantly better than that.
This commit is contained in:
parent
85baeb6375
commit
2fbb6d05a9
1 changed files with 12 additions and 8 deletions
|
@ -399,10 +399,11 @@ Complete list of currently available key bindings:
|
|||
(defun notmuch-search-properties-in-region (property beg end)
|
||||
(save-excursion
|
||||
(let ((output nil)
|
||||
(last-line (line-number-at-pos end)))
|
||||
(last-line (line-number-at-pos end))
|
||||
(max-line (- (line-number-at-pos (point-max)) 2)))
|
||||
(goto-char beg)
|
||||
(beginning-of-line)
|
||||
(while (<= (line-number-at-pos) last-line)
|
||||
(while (<= (line-number-at-pos) (min last-line max-line))
|
||||
(setq output (cons (get-text-property (point) property) output))
|
||||
(forward-line 1))
|
||||
output)))
|
||||
|
@ -497,9 +498,10 @@ and will also appear in a buffer named \"*Notmuch errors*\"."
|
|||
(defun notmuch-search-get-tags-region (beg end)
|
||||
(save-excursion
|
||||
(let ((output nil)
|
||||
(last-line (line-number-at-pos end)))
|
||||
(last-line (line-number-at-pos end))
|
||||
(max-line (- (line-number-at-pos (point-max)) 2)))
|
||||
(goto-char beg)
|
||||
(while (<= (line-number-at-pos) last-line)
|
||||
(while (<= (line-number-at-pos) (min last-line max-line))
|
||||
(setq output (append output (notmuch-search-get-tags)))
|
||||
(forward-line 1))
|
||||
output)))
|
||||
|
@ -512,9 +514,10 @@ and will also appear in a buffer named \"*Notmuch errors*\"."
|
|||
(let ((search-id-string (mapconcat 'identity (notmuch-search-find-thread-id-region beg end) " or ")))
|
||||
(notmuch-call-notmuch-process "tag" (concat "+" tag) search-id-string)
|
||||
(save-excursion
|
||||
(let ((last-line (line-number-at-pos end)))
|
||||
(let ((last-line (line-number-at-pos end))
|
||||
(max-line (- (line-number-at-pos (point-max)) 2)))
|
||||
(goto-char beg)
|
||||
(while (<= (line-number-at-pos) last-line)
|
||||
(while (<= (line-number-at-pos) (min last-line max-line))
|
||||
(notmuch-search-set-tags (delete-dups (sort (cons tag (notmuch-search-get-tags)) 'string<)))
|
||||
(forward-line))))))
|
||||
|
||||
|
@ -526,9 +529,10 @@ and will also appear in a buffer named \"*Notmuch errors*\"."
|
|||
(let ((search-id-string (mapconcat 'identity (notmuch-search-find-thread-id-region beg end) " or ")))
|
||||
(notmuch-call-notmuch-process "tag" (concat "-" tag) search-id-string)
|
||||
(save-excursion
|
||||
(let ((last-line (line-number-at-pos end)))
|
||||
(let ((last-line (line-number-at-pos end))
|
||||
(max-line (- (line-number-at-pos (point-max)) 2)))
|
||||
(goto-char beg)
|
||||
(while (<= (line-number-at-pos) last-line)
|
||||
(while (<= (line-number-at-pos) (min last-line max-line))
|
||||
(notmuch-search-set-tags (delete tag (notmuch-search-get-tags)))
|
||||
(forward-line))))))
|
||||
|
||||
|
|
Loading…
Reference in a new issue