X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=emacs%2Fnotmuch.el;h=be09f424a953c0686f552b7dd012ef5747b3d01a;hp=517c53a5d3784a5c2d8362f319b2e436ac640d19;hb=db96d67ba2e2ae01bc3139a3a22cc5433880cbae;hpb=fec5622add1a4e9f305c16e96143439ee22a5c58 diff --git a/emacs/notmuch.el b/emacs/notmuch.el index 517c53a5..be09f424 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -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,38 +498,39 @@ 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))) (defun notmuch-search-add-tag-thread (tag) - (notmuch-call-notmuch-process "tag" (concat "+" tag) (notmuch-search-find-thread-id)) - (notmuch-search-set-tags (delete-dups (sort (cons tag (notmuch-search-get-tags)) 'string<)))) + (notmuch-search-add-tag-region tag (point) (point))) (defun notmuch-search-add-tag-region (tag beg end) (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)))))) (defun notmuch-search-remove-tag-thread (tag) - (notmuch-call-notmuch-process "tag" (concat "-" tag) (notmuch-search-find-thread-id)) - (notmuch-search-set-tags (delete tag (notmuch-search-get-tags)))) + (notmuch-search-remove-tag-region tag (point) (point))) (defun notmuch-search-remove-tag-region (tag beg end) (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))))))