From: Lars Ingebrigtsen Date: Sat, 16 Apr 2022 14:07:25 +0000 (+0200) Subject: Fix NEWS tag commands X-Git-Tag: emacs-29.0.90~1931^2~523 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=5752a839e59a2159203f7665b9a5ab740250b1ab;p=emacs.git Fix NEWS tag commands * lisp/textmodes/emacs-news-mode.el (emacs-news-next-untagged-entry): Fix logic. (emacs-news-count-untagged-entries): Add new command and keystroke. --- diff --git a/lisp/textmodes/emacs-news-mode.el b/lisp/textmodes/emacs-news-mode.el index b56cf13adb0..88b4740ac86 100644 --- a/lisp/textmodes/emacs-news-mode.el +++ b/lisp/textmodes/emacs-news-mode.el @@ -40,7 +40,8 @@ :version "29.1") (defvar-keymap emacs-news-mode-map - "C-c C-s" #'emacs-news-next-untagged-entry) + "C-c C-s" #'emacs-news-next-untagged-entry + "C-c C-n" #'emacs-news-count-untagged-entries) (defvar emacs-news-mode-font-lock-keywords `(("^---$" 0 'emacs-news-does-not-need-documentation) @@ -91,25 +92,39 @@ ;; progress if calling this command repeatedly. (forward-line 1) (while (and (not found) - (re-search-forward "\\(\\*+\\) " nil t) - (not (save-excursion - (forward-line -1) - (looking-at "---$\\|\\+\\+\\+$")))) - ;; We have an entry without a tag before it, but check whether - ;; it's a heading (which we can determine if the next entry has - ;; more asterisks). - (let ((level (length (match-string 1)))) - (when (save-excursion - (re-search-forward "^\\(\\*+\\) " nil t)) - (when (<= (length (match-string 1)) level) - ;; It wasn't a sub-heading, so we've found one. - (setq found t))))) + (re-search-forward "\\(\\*+\\) " nil t)) + (unless (save-excursion + (forward-line -1) + (looking-at "---$\\|\\+\\+\\+$")) + ;; We have an entry without a tag before it, but check whether + ;; it's a heading (which we can determine if the next entry has + ;; more asterisks). + (let ((level (length (match-string 1)))) + (when (save-excursion + (re-search-forward "^\\(\\*+\\) " nil t)) + (when (<= (length (match-string 1)) level) + ;; It wasn't a sub-heading, so we've found one. + (setq found t)))))) (if found (progn (message "Untagged entry") - (beginning-of-line)) + (beginning-of-line) + t) (message "No further untagged entries") - (goto-char start)))) + (goto-char start) + nil))) + +(defun emacs-news-count-untagged-entries () + "Say how many untagged entries there are in the current NEWS buffer." + (interactive nil emacs-news-mode) + (save-excursion + (goto-char (point-min)) + (let ((i 0)) + (while (emacs-news-next-untagged-entry) + (setq i (1+ i))) + (message (if (= i 1) + "There's 1 untagged entry" + (format "There's %s untagged entries" i)))))) (defun emacs-news--buttonize () "Make manual and symbol references into buttons."