commit 5fdf4fc07df7dd897931efb5dbf5f26dfaff9274 (HEAD, refs/remotes/origin/master) Author: Juri Linkov Date: Sun Mar 24 23:55:07 2019 +0200 i18n: Add function ngettext for pluralization. * lisp/international/mule-cmds.el (ngettext): New function. https://lists.gnu.org/archive/html/emacs-devel/2019-03/msg00586.html * lisp/replace.el (flush-lines, how-many, occur-1, occur-engine) (perform-replace): Use ngettext. * lisp/progmodes/grep.el (grep-exit-message): Use ngettext. (grep-mode-font-lock-keywords): Match both singular and plural form of "matches". diff --git a/etc/NEWS b/etc/NEWS index cb485992b8..bbba59c549 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1364,6 +1364,11 @@ Now, such rx expressions generate an error. * Lisp Changes in Emacs 27.1 +** i18n (internationalization) + +*** ngettext can be used now to return the right plural form +according to the given numeric value. + +++ ** inhibit-null-byte-detection is renamed to inhibit-nul-byte-detection diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el index 5f87d89941..035932e395 100644 --- a/lisp/international/mule-cmds.el +++ b/lisp/international/mule-cmds.el @@ -2798,6 +2798,20 @@ See also `locale-charset-language-names', `locale-language-names', 'a4))))))) nil) +;;; i18n (internationalization) + +(defun ngettext (msgid msgid_plural n) + "Return the plural form of the translation of the string. +This function is similar to the `gettext' function as it finds the message +catalogs in the same way. But it takes two extra arguments. The MSGID +parameter must contain the singular form of the string to be converted. +It is also used as the key for the search in the catalog. +The MSGID_PLURAL parameter is the plural form. The parameter N is used +to determine the plural form. If no message catalog is found MSGID is +returned if N is equal to 1, otherwise MSGID_PLURAL." + (if (= n 1) msgid msgid_plural)) + + ;;; Character property (put 'char-code-property-table 'char-table-extra-slots 5) diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el index a5427dd8b7..c0f47159c9 100644 --- a/lisp/progmodes/grep.el +++ b/lisp/progmodes/grep.el @@ -459,7 +459,7 @@ abbreviated part can also be toggled with ;; remove match from grep-regexp-alist before fontifying ("^Grep[/a-zA-Z]* started.*" (0 '(face nil compilation-message nil help-echo nil mouse-face nil) t)) - ("^Grep[/a-zA-Z]* finished with \\(?:\\(\\(?:[0-9]+ \\)?matches found\\)\\|\\(no matches found\\)\\).*" + ("^Grep[/a-zA-Z]* finished with \\(?:\\(\\(?:[0-9]+ \\)?match\\(?:es\\)? found\\)\\|\\(no matches found\\)\\).*" (0 '(face nil compilation-message nil help-echo nil mouse-face nil) t) (1 compilation-info-face nil t) (2 compilation-warning-face nil t)) @@ -552,7 +552,10 @@ Set up `compilation-exit-message-function' and run `grep-setup-hook'." ;; so the buffer is still unmodified if there is no output. (cond ((and (zerop code) (buffer-modified-p)) (if (> grep-num-matches-found 0) - (cons (format "finished with %d matches found\n" grep-num-matches-found) + (cons (format (ngettext "finished with %d match found\n" + "finished with %d matches found\n" + grep-num-matches-found) + grep-num-matches-found) "matched") '("finished with matches found\n" . "matched"))) ((not (buffer-modified-p)) diff --git a/lisp/replace.el b/lisp/replace.el index 59ad1a375b..318a9fb025 100644 --- a/lisp/replace.el +++ b/lisp/replace.el @@ -983,7 +983,10 @@ also print the number." (progn (forward-line 1) (point))) (setq count (1+ count)))) (set-marker rend nil) - (when interactive (message "Deleted %d matching lines" count)) + (when interactive (message (ngettext "Deleted %d matching line" + "Deleted %d matching lines" + count) + count)) count)) (defun how-many (regexp &optional rstart rend interactive) @@ -1032,9 +1035,10 @@ a previously found match." (if (= opoint (point)) (forward-char 1) (setq count (1+ count)))) - (when interactive (message "%d occurrence%s" - count - (if (= count 1) "" "s"))) + (when interactive (message (ngettext "%d occurrence" + "%d occurrences" + count) + count)) count))) @@ -1617,11 +1621,12 @@ See also `multi-occur'." (not (eq occur-excluded-properties t)))))) (let* ((bufcount (length active-bufs)) (diff (- (length bufs) bufcount))) - (message "Searched %d buffer%s%s; %s match%s%s" - bufcount (if (= bufcount 1) "" "s") + (message "Searched %d %s%s; %s %s%s" + bufcount + (ngettext "buffer" "buffers" bufcount) (if (zerop diff) "" (format " (%d killed)" diff)) (if (zerop count) "no" (format "%d" count)) - (if (= count 1) "" "es") + (ngettext "match" "matches" count) ;; Don't display regexp if with remaining text ;; it is longer than window-width. (if (> (+ (length (or (get-text-property 0 'isearch-string regexp) @@ -1856,14 +1861,15 @@ See also `multi-occur'." (let ((beg (point)) end) (insert (propertize - (format "%d match%s%s%s in buffer: %s%s\n" - matches (if (= matches 1) "" "es") + (format "%d %s%s%s in buffer: %s%s\n" + matches + (ngettext "match" "matches" matches) ;; Don't display the same number of lines ;; and matches in case of 1 match per line. (if (= lines matches) - "" (format " in %d line%s" + "" (format " in %d %s" lines - (if (= lines 1) "" "s"))) + (ngettext "line" "lines" lines))) ;; Don't display regexp for multi-buffer. (if (> (length buffers) 1) "" (occur-regexp-descr regexp)) @@ -1889,13 +1895,15 @@ See also `multi-occur'." (goto-char (point-min)) (let ((beg (point)) end) - (insert (format "%d match%s%s total%s:\n" - global-matches (if (= global-matches 1) "" "es") + (insert (format "%d %s%s total%s:\n" + global-matches + (ngettext "match" "matches" global-matches) ;; Don't display the same number of lines ;; and matches in case of 1 match per line. (if (= global-lines global-matches) - "" (format " in %d line%s" - global-lines (if (= global-lines 1) "" "s"))) + "" (format " in %d %s" + global-lines + (ngettext "line" "lines" global-lines))) (occur-regexp-descr regexp))) (setq end (point)) (when title-face @@ -2730,10 +2738,10 @@ characters." (1+ num-replacements)))))) (when (and (eq def 'undo-all) (null (zerop num-replacements))) - (message "Undid %d %s" num-replacements - (if (= num-replacements 1) - "replacement" - "replacements")) + (message (ngettext "Undid %d replacement" + "Undid %d replacements" + num-replacements) + num-replacements) (ding 'no-terminate) (sit-for 1))) (setq replaced nil last-was-undo t last-was-act-and-show nil))) @@ -2859,9 +2867,10 @@ characters." last-was-act-and-show nil)))))) (replace-dehighlight)) (or unread-command-events - (message "Replaced %d occurrence%s%s" + (message (ngettext "Replaced %d occurrence%s" + "Replaced %d occurrences%s" + replace-count) replace-count - (if (= replace-count 1) "" "s") (if (> (+ skip-read-only-count skip-filtered-count skip-invisible-count) commit 36535caf9621f984f7f95d4def09bdb0ae2f1d2a Author: Juri Linkov Date: Sun Mar 24 23:19:55 2019 +0200 * lisp/progmodes/xref.el (xref--show-xrefs): Push mark. (Bug#34908) diff --git a/etc/NEWS b/etc/NEWS index 9f569a7367..cb485992b8 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -671,6 +671,10 @@ mouse click event, and is intended to be bound to a mouse event. Previously, setting 'xref-marker-ring-length' would only take effect if set before 'xref.el' was loaded. +--- +*** xref-find-definitions now sets the mark at the buffer position +where it was invoked + ** Ecomplete *** The ecomplete sorting has changed to a decay-based algorithm. diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index 6974d00048..aed92f8db6 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -797,6 +797,7 @@ Return an alist of the form ((FILENAME . (XREF ...)) ...)." (defvar xref--read-pattern-history nil) (defun xref--show-xrefs (xrefs display-action &optional always-show-list) + (unless (region-active-p) (push-mark nil t)) (cond ((and (not (cdr xrefs)) (not always-show-list)) (xref-push-marker-stack) commit 03e916beb0186f3707cd238650298870bf471575 Author: Basil L. Contovounesios Date: Sun Mar 24 14:12:58 2019 +0000 Fix Gnus duplicate article unsuppression * lisp/gnus/gnus-sum.el (gnus-summary-mode-group): Declare before first use to silence byte-compiler. (gnus-summary-select-article): Simplify boolean expression. (gnus-summary-move-article): Do not try to unsuppress article when duplicate suppression is disabled. (bug#34973, bug#34974) diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el index 85c902a5e4..f09c0fbb58 100644 --- a/lisp/gnus/gnus-sum.el +++ b/lisp/gnus/gnus-sum.el @@ -3053,6 +3053,11 @@ When FORCE, rebuild the tool bar." (defvar bidi-paragraph-direction) +(defvar gnus-summary-mode-group nil + "Variable for communication with `gnus-summary-mode'. +Allows the `gnus-newsgroup-name' local variable to be set before +the summary mode hooks are run.") + (define-derived-mode gnus-summary-mode gnus-mode "Summary" "Major mode for reading articles. \\ @@ -3468,11 +3473,6 @@ display only a single character." (point) (current-buffer)))))) -(defvar gnus-summary-mode-group nil - "Variable for communication with `gnus-summary-mode'. -Allows the `gnus-newsgroup-name' local variable to be set before -the summary mode hooks are run.") - (defun gnus-summary-setup-buffer (group) "Initialize summary buffer for GROUP. This function does all setup work that relies on the specific @@ -7744,7 +7744,7 @@ be displayed." (unless (derived-mode-p 'gnus-summary-mode) (set-buffer gnus-summary-buffer)) (let ((article (or article (gnus-summary-article-number))) - (all-headers (not (not all-headers))) ;Must be t or nil. + (all-headers (and all-headers t)) ; Must be t or nil. gnus-summary-display-article-function) (and (not pseudo) (gnus-summary-article-pseudo-p article) @@ -9978,13 +9978,12 @@ ACTION can be either `move' (the default), `crosspost' or `copy'." (crosspost "Crosspost" "Crossposting"))) (copy-buf (save-excursion (nnheader-set-temp-buffer " *copy article*"))) - art-group to-method new-xref article to-groups + art-group to-method new-xref to-groups articles-to-update-marks encoded) (unless (assq action names) (error "Unknown action %s" action)) ;; Read the newsgroup name. - (when (and (not to-newsgroup) - (not select-method)) + (unless (or to-newsgroup select-method) (if (and gnus-move-split-methods (not (and (memq gnus-current-article articles) @@ -10029,8 +10028,7 @@ ACTION can be either `move' (the default), `crosspost' or `copy'." (or (car select-method) (gnus-group-decoded-name to-newsgroup)) articles) - (while articles - (setq article (pop articles)) + (dolist (article articles) ;; Set any marks that may have changed in the summary buffer. (when gnus-preserve-marks (gnus-summary-push-marks-to-backend article)) @@ -10039,8 +10037,9 @@ ACTION can be either `move' (the default), `crosspost' or `copy'." (cond ;; Move the article. ((eq action 'move) - ;; Remove this article from future suppression. - (gnus-dup-unsuppress-article article) + (when gnus-suppress-duplicates + ;; Remove this article from future suppression. + (gnus-dup-unsuppress-article article)) (let* ((from-method (gnus-find-method-for-group gnus-newsgroup-name)) (to-method (or select-method commit d2a9273c77182e8aa3468fbb5c71f2729639c465 Author: Paul Eggert Date: Sun Mar 24 08:25:51 2019 -0700 * src/lisp.h (primary_thread): Remove unused decl. diff --git a/src/lisp.h b/src/lisp.h index c33c311b4a..2508e2b804 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -4218,7 +4218,6 @@ extern void syms_of_module (void); #endif /* Defined in thread.c. */ -extern struct thread_state primary_thread; extern void mark_threads (void); extern void unmark_main_thread (void); commit cf6950366bd2b2aad4daa2d601bd8ccdb50df700 Author: Michael Albinus Date: Sun Mar 24 14:24:31 2019 +0100 Bind `enable-local-variables' in `hack-connection-local-variables' * lisp/files-x.el (hack-connection-local-variables): Bind `enable-local-variables', instead of re-declaring `safe-local-variable-p'. diff --git a/lisp/files-x.el b/lisp/files-x.el index 5353e54158..b71e9204f3 100644 --- a/lisp/files-x.el +++ b/lisp/files-x.el @@ -31,7 +31,6 @@ ;;; Code: (eval-when-compile (require 'subr-x)) ; for string-trim-right -(eval-when-compile (require 'cl-lib)) ; for cl-letf ;;; Commands to add/delete file-local/directory-local variables. @@ -690,7 +689,7 @@ This does nothing if `enable-connection-local-variables' is nil." ;; Push them to `file-local-variables-alist'. Connection-local ;; variables do not appear from external files. So we can regard ;; them as safe. - (cl-letf (((symbol-function 'safe-local-variable-p) (lambda (_sym _val) t))) + (let ((enable-local-variables :all)) (hack-local-variables-filter connection-local-variables-alist nil)))) ;;;###autoload