aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/replace.el
diff options
context:
space:
mode:
authorJuri Linkov2019-03-24 23:55:07 +0200
committerJuri Linkov2019-03-24 23:55:07 +0200
commit5fdf4fc07df7dd897931efb5dbf5f26dfaff9274 (patch)
tree807fd09f411bd670cb0f7bc7834469366e514036 /lisp/replace.el
parent36535caf9621f984f7f95d4def09bdb0ae2f1d2a (diff)
downloademacs-5fdf4fc07df7dd897931efb5dbf5f26dfaff9274.tar.gz
emacs-5fdf4fc07df7dd897931efb5dbf5f26dfaff9274.zip
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".
Diffstat (limited to 'lisp/replace.el')
-rw-r--r--lisp/replace.el51
1 files changed, 30 insertions, 21 deletions
diff --git a/lisp/replace.el b/lisp/replace.el
index 59ad1a375b8..318a9fb0253 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -983,7 +983,10 @@ also print the number."
983 (progn (forward-line 1) (point))) 983 (progn (forward-line 1) (point)))
984 (setq count (1+ count)))) 984 (setq count (1+ count))))
985 (set-marker rend nil) 985 (set-marker rend nil)
986 (when interactive (message "Deleted %d matching lines" count)) 986 (when interactive (message (ngettext "Deleted %d matching line"
987 "Deleted %d matching lines"
988 count)
989 count))
987 count)) 990 count))
988 991
989(defun how-many (regexp &optional rstart rend interactive) 992(defun how-many (regexp &optional rstart rend interactive)
@@ -1032,9 +1035,10 @@ a previously found match."
1032 (if (= opoint (point)) 1035 (if (= opoint (point))
1033 (forward-char 1) 1036 (forward-char 1)
1034 (setq count (1+ count)))) 1037 (setq count (1+ count))))
1035 (when interactive (message "%d occurrence%s" 1038 (when interactive (message (ngettext "%d occurrence"
1036 count 1039 "%d occurrences"
1037 (if (= count 1) "" "s"))) 1040 count)
1041 count))
1038 count))) 1042 count)))
1039 1043
1040 1044
@@ -1617,11 +1621,12 @@ See also `multi-occur'."
1617 (not (eq occur-excluded-properties t)))))) 1621 (not (eq occur-excluded-properties t))))))
1618 (let* ((bufcount (length active-bufs)) 1622 (let* ((bufcount (length active-bufs))
1619 (diff (- (length bufs) bufcount))) 1623 (diff (- (length bufs) bufcount)))
1620 (message "Searched %d buffer%s%s; %s match%s%s" 1624 (message "Searched %d %s%s; %s %s%s"
1621 bufcount (if (= bufcount 1) "" "s") 1625 bufcount
1626 (ngettext "buffer" "buffers" bufcount)
1622 (if (zerop diff) "" (format " (%d killed)" diff)) 1627 (if (zerop diff) "" (format " (%d killed)" diff))
1623 (if (zerop count) "no" (format "%d" count)) 1628 (if (zerop count) "no" (format "%d" count))
1624 (if (= count 1) "" "es") 1629 (ngettext "match" "matches" count)
1625 ;; Don't display regexp if with remaining text 1630 ;; Don't display regexp if with remaining text
1626 ;; it is longer than window-width. 1631 ;; it is longer than window-width.
1627 (if (> (+ (length (or (get-text-property 0 'isearch-string regexp) 1632 (if (> (+ (length (or (get-text-property 0 'isearch-string regexp)
@@ -1856,14 +1861,15 @@ See also `multi-occur'."
1856 (let ((beg (point)) 1861 (let ((beg (point))
1857 end) 1862 end)
1858 (insert (propertize 1863 (insert (propertize
1859 (format "%d match%s%s%s in buffer: %s%s\n" 1864 (format "%d %s%s%s in buffer: %s%s\n"
1860 matches (if (= matches 1) "" "es") 1865 matches
1866 (ngettext "match" "matches" matches)
1861 ;; Don't display the same number of lines 1867 ;; Don't display the same number of lines
1862 ;; and matches in case of 1 match per line. 1868 ;; and matches in case of 1 match per line.
1863 (if (= lines matches) 1869 (if (= lines matches)
1864 "" (format " in %d line%s" 1870 "" (format " in %d %s"
1865 lines 1871 lines
1866 (if (= lines 1) "" "s"))) 1872 (ngettext "line" "lines" lines)))
1867 ;; Don't display regexp for multi-buffer. 1873 ;; Don't display regexp for multi-buffer.
1868 (if (> (length buffers) 1) 1874 (if (> (length buffers) 1)
1869 "" (occur-regexp-descr regexp)) 1875 "" (occur-regexp-descr regexp))
@@ -1889,13 +1895,15 @@ See also `multi-occur'."
1889 (goto-char (point-min)) 1895 (goto-char (point-min))
1890 (let ((beg (point)) 1896 (let ((beg (point))
1891 end) 1897 end)
1892 (insert (format "%d match%s%s total%s:\n" 1898 (insert (format "%d %s%s total%s:\n"
1893 global-matches (if (= global-matches 1) "" "es") 1899 global-matches
1900 (ngettext "match" "matches" global-matches)
1894 ;; Don't display the same number of lines 1901 ;; Don't display the same number of lines
1895 ;; and matches in case of 1 match per line. 1902 ;; and matches in case of 1 match per line.
1896 (if (= global-lines global-matches) 1903 (if (= global-lines global-matches)
1897 "" (format " in %d line%s" 1904 "" (format " in %d %s"
1898 global-lines (if (= global-lines 1) "" "s"))) 1905 global-lines
1906 (ngettext "line" "lines" global-lines)))
1899 (occur-regexp-descr regexp))) 1907 (occur-regexp-descr regexp)))
1900 (setq end (point)) 1908 (setq end (point))
1901 (when title-face 1909 (when title-face
@@ -2730,10 +2738,10 @@ characters."
2730 (1+ num-replacements)))))) 2738 (1+ num-replacements))))))
2731 (when (and (eq def 'undo-all) 2739 (when (and (eq def 'undo-all)
2732 (null (zerop num-replacements))) 2740 (null (zerop num-replacements)))
2733 (message "Undid %d %s" num-replacements 2741 (message (ngettext "Undid %d replacement"
2734 (if (= num-replacements 1) 2742 "Undid %d replacements"
2735 "replacement" 2743 num-replacements)
2736 "replacements")) 2744 num-replacements)
2737 (ding 'no-terminate) 2745 (ding 'no-terminate)
2738 (sit-for 1))) 2746 (sit-for 1)))
2739 (setq replaced nil last-was-undo t last-was-act-and-show nil))) 2747 (setq replaced nil last-was-undo t last-was-act-and-show nil)))
@@ -2859,9 +2867,10 @@ characters."
2859 last-was-act-and-show nil)))))) 2867 last-was-act-and-show nil))))))
2860 (replace-dehighlight)) 2868 (replace-dehighlight))
2861 (or unread-command-events 2869 (or unread-command-events
2862 (message "Replaced %d occurrence%s%s" 2870 (message (ngettext "Replaced %d occurrence%s"
2871 "Replaced %d occurrences%s"
2872 replace-count)
2863 replace-count 2873 replace-count
2864 (if (= replace-count 1) "" "s")
2865 (if (> (+ skip-read-only-count 2874 (if (> (+ skip-read-only-count
2866 skip-filtered-count 2875 skip-filtered-count
2867 skip-invisible-count) 2876 skip-invisible-count)