aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/replace.el (unfollow)
Commit message (Collapse)AuthorFilesLines
2020-05-31occur: Add bindings for next-error-no-selectTino Calancha1-1/+71
Make the navigation in the occur buffer closer to the navigation in the compilation buffer. Add bindings to navigate the occur matches (Bug#39121). Honor `next-error-highlight' and `next-error-highlight-no-select' when navigating the occurrences. * lisp/replace.el (occur-highlight-regexp, occur-highlight-overlay): New variables. (occur-1): Set `occur-highlight-regexp' to the searched regexp. (occur-goto-locus-delete-o, occur--highlight-occurrence): New defuns. (occur-mode-display-occurrence, occur-mode-goto-occurrence): Use `occur--highlight-occurrence'. (occur-mode-map): Bind n to `next-error-no-select' and p to `previous-error-no-select' * etc/NEWS (Changes in Specialized Modes and Packages in Emacs 28.1): Announce this change. * test/lisp/replace-tests.el (replace-tests-with-highlighted-occurrence): Add helper macro. (occur-highlight-occurrence): Add test.
2020-05-02Document effect of 'search-upper-case' on replacement commandsEli Zaretskii1-14/+21
* doc/emacs/search.texi (Replacement and Lax Matches): Document the role of 'search-upper-case' in replacement commands. (Lax Search): Document the value 'not-yanks' of 'search-upper-case' where the variable itself is documented. * lisp/replace.el (query-replace-regexp, query-replace): Mention 'search-upper-case' and its effect in doc strings. (Bug#40940)
2020-03-04Update default-directory in occur buffer (bug#39608)Stéphane Boucher1-1/+5
* lisp/replace.el (occur-1): Update default-directory in occur buffer. Copyright-paperwork-exempt: yes
2020-02-23* lisp/replace.el (occur-engine-line): Revert part of fb16313025 (bug#39597)Juri Linkov1-2/+4
; Do not merge to master.
2020-01-01Update copyright year to 2020Paul Eggert1-1/+1
Run "TZ=UTC0 admin/update-copyright $(git ls-files)".
2019-10-09; Fix typo in previous commitRobert Pluim1-1/+1
* lisp/replace.el (query-replace-read-from): Fix typo in docstring.
2019-10-09Improve doc strings in replace.elEli Zaretskii1-10/+26
* lisp/replace.el (query-replace-read-from) (query-replace-compile-replacement, query-replace-read-to) (replace-string, replace-regexp, occur-mode-goto-occurrence) (occur-next-error, occur-rename-buffer, multi-occur) (multi-occur-in-matching-buffers): Describe all arguments in doc strings. (Bug#31207)
2019-09-17Backport: Fix an assignment to free variable warningTino Calancha1-1/+1
It fixes a bug introduced by commit 'query-replace-regexp undo: Update next-replacement after undo' (30c4f35a6fc8a6507930923766c3126ac1c2063f) See https://lists.gnu.org/archive/html/emacs-devel/2019-09/msg00364.html * lisp/replace.el(perform-replace): Rename variable to next-replacement-replaced. (cherry picked from commit cbc10ec71e9f189e8d6fd5c6927aec4872e0fd96)
2019-09-17Fix an assignment to free variable warningTino Calancha1-1/+1
It fixes a bug introduced by commit 'query-replace-regexp undo: Update next-replacement after undo' (30c4f35a6fc8a6507930923766c3126ac1c2063f) See https://lists.gnu.org/archive/html/emacs-devel/2019-09/msg00364.html * lisp/replace.el(perform-replace): Rename variable to next-replacement-replaced.
2019-09-09query-replace-regexp undo: Update next-replacement after undoTino Calancha1-6/+8
* lisp/replace.el (perform-replace): Rename the local binding to not shadow next-replacement. Update next-replacement after undo (Bug#37287). * test/lisp/replace-tests.el (query-replace-undo-bug37287): Add test. (query-replace-undo-bug37073): Tweak this test.
2019-08-19Fix query-replace-regexp undo featureTino Calancha1-2/+5
Ensure that non-regexp strings used with `looking-at' are quoted. * lisp/replace.el (perform-replace): Quote regexp (Bug#37073). * test/lisp/replace-tests.el (replace-tests-perform-replace-regexp-flag): New variable. (replace-tests-with-undo): Use it. (query-replace-undo-bug37073): Add tests.
2019-07-15Tweak mouse-face highlighting of Occur buffersLars Ingebrigtsen1-7/+10
* lisp/replace.el (occur-engine): Ensure that the mouse highlight is done over the entire line (bug#27846).
2019-07-12Better match-data handling in perform-replaceJuri Linkov1-19/+20
* lisp/replace.el (perform-replace): Don't wrap replace-highlight in save-match-data. Use `(nth 0 real-match-data)' instead of `(match-beginning 0)' after replace-highlight. (Bug#36328)
2019-07-08* lisp/replace.el (perform-replace): Move save-match-data hereJuri Linkov1-13/+14
from replace-highlight for isearch-lazy-highlight-new-loop (bug#36328).
2019-07-05* lisp/replace.el (replace-highlight): Add save-match-data (bug#36328)Juri Linkov1-1/+5
* lisp/term/tty-colors.el (tty-color-canonicalize): Replace string-match with string-match-p. Thanks to Jayden Navarro <jayden@yugabyte.com> and Alan Mackenzie <acm@muc.de>
2019-05-25Go back to "Maintainer: emacs-devel@gnu.org"Paul Eggert1-0/+1
Restore lines saying "Maintainer: emacs-devel@gnu.org" when there is no special maintainer for a file. Although this wasn't documented it was common practice and removing the lines didn't have consensus.
2019-05-19Fixes for "Maintainer:" and related linesPaul Eggert1-1/+0
Mostly, this just removes "Maintainer: emacs-devel@gnu.org" lines, which are not that useful. It also cleans up and regularizes a few similar lines.
2019-04-10Inhibit displaying help buffer in main window in perform-replaceJuri Linkov1-16/+18
* lisp/replace.el (perform-replace): Use display-buffer-overriding-action with inhibit-same-window to prevent the help buffer from being displayed in the main window. (Bug#34972) Author: Michał Krzywkowski <k.michal@zoho.com> Copyright-paperwork-exempt: yes
2019-03-24i18n: Add function ngettext for pluralization.Juri Linkov1-21/+30
* 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".
2019-02-28* lisp/replace.el (flush-lines): Return the number of deleted lines.Juri Linkov1-9/+12
When called interactively, also print the number. (Bug#34520) * doc/emacs/search.texi (Other Repeating Search): Update flush-lines that prints the number of deleted lines.
2019-01-01Update copyright year to 2019Paul Eggert1-1/+1
Run 'TZ=UTC0 admin/update-copyright $(git ls-files)'.
2018-12-19More font-lock improvements for diff-modeJuri Linkov1-4/+2
* lisp/vc/diff-mode.el (diff-font-lock-keywords): Use diff-header face for git index lines (like already used for bzr index lines). Use diff-file-header face for binary file headers. (diff-find-source-location): Use expand-file-name for vc-find-revision. (diff--font-lock-prettify): Use diff-indicator-* faces for left-fringe indicators. (diff-syntax-fontify-props): Optimize to not use text-property-not-all for font-lock-ensure. * lisp/replace.el (occur-engine-line): Simplify to use font-lock-ensure without text-property-not-all.
2018-12-10Fix occur for non-nil list-matching-lines-jump-to-current-line (bug#33476)Juri Linkov1-6/+6
* lisp/replace.el (occur-engine): Move orig-line let-binding higher. Don't use start-line in forward-line.
2018-12-10Guard occur against an undefined orig-lineRaimon Grau1-1/+3
; Not to be merged to master * lisp/replace.el (occur-engine): Avoid inserting the current line if orig-line is nil. This happens, for example, when reverting an occur buffer with `list-matching-lines-jump-to-current-line' set to t. (Bug#33476)
2018-10-09* lisp/replace.el (occur--garbage-collect-revert-args): New functionStefan Monnier1-26/+30
(occur-mode, occur-1): Use it. (occur--region-start, occur--region-end, occur--region-start-line) (occur--orig-line): Remove vars. (occur-engine): Fix left over use of occur--region-start-line.
2018-10-09Revert part of last commitEli Zaretskii1-13/+1
* lisp/replace.el (occur-revert-function): Revert last change, as it's no longer needed. (Bug#32987)
2018-10-09* lisp/replace.el: Rework implementation of the occur regionStefan Monnier1-112/+92
Put the region info in the "list of buffers" used for multi-occur. (occur--parse-occur-buffer): Remove. (occur): Pass the region to occur-1 as an overlay. (occur-1): 'bufs' is now a list of buffers or overlays. (occur-engine): 'buffers' is now a list of buffers or overlays.
2018-10-09Unbreak 'revert-buffer' in Occur buffersEli Zaretskii1-8/+8
* lisp/replace.el (occur-revert-function): Use the value of occur-revert-function from the correct buffer. (Bug#32987) * test/lisp/replace-tests.el (replace-occur-revert-bug32543) (replace-occur-revert-bug32987): New tests.
2018-09-21Fix a previous commitTino Calancha1-13/+9
Suggested by Stefan Monnier here: https://lists.gnu.org/archive/html/emacs-devel/2018-09/msg00783.html * lisp/replace.el (occur--parse-occur-buffer): Since point is at the beginning of the buffer, use `point'. (occur-revert-function): Prefer `pcase-let' and `point-min'. Check whether `region-start' or `region-end' are non-nil.
2018-09-18Fix bug 32543Tino Calancha1-3/+36
Store the region and orig line into the *Occur* header line. Retrieve this information in `occur-revert-function'. * lisp/replace.el (occur--parse-occur-buffer): New defun. (occur-revert-function): Use it. (occur-engine): Store region and original position as text properties into the *Occur* header line. * lisp/replace.el (occur-engine): Add sensible default values for (occur--orig-line and nlines.
2018-06-03query-replace undo: Handle when user edits the replacement stringTino Calancha1-1/+2
* lisp/replace.el (perform-replace): Update the replacement string after the user edit it (Fix Bug#31538). * test/lisp/replace-tests.el (query-replace-undo-bug31538): New test. Backport: (cherry picked from commits ea133e04f49afa7928e49a3ac4a85b47f6f13f01 and 7dcfdf5b14325ae7996f272f14c72810d7c84944)
2018-06-03Backport: Fix corner case in query-replace-regexp undoTino Calancha1-0/+4
This commit fixes Bug#31492. * lisp/replace.el (replace-match-maybe-edit): Preserve match data. * test/lisp/replace-tests.el (query-replace-undo-bug31492): Add test. (cherry picked from commit bab73230d1be1fe394b7269c1365ef6fb1a5d9b3)
2018-06-03Backport: Preserve case in query-replace undoTino Calancha1-0/+1
If the user query and replaces 'foo' with 'BAR', then undo must comeback to 'foo', not to 'FOO' (Bug#31073). * lisp/replace.el (perform-replace): Bind nocasify to non-nil value during undo/undo-all actions. * test/lisp/replace-tests.el (query-replace-undo-bug31073): Add test. (cherry picked from commit 32dc0cb1b5ae895d237c7118ccaeb084715934fd)
2018-05-26query-replace undo: Handle when user edits the replacement stringTino Calancha1-1/+2
* lisp/replace.el (perform-replace): Update the replacement string after the user edit it (Fix Bug#31538). * test/lisp/replace-tests.el (replace-tests-clauses): New function. (replace-tests-bind-read-string): New variable. (replace-tests-with-undo): Macro to create boilerplate code. (query-replace-undo-bug31073): Use it. (query-replace-undo-bug31538): New test.
2018-05-23Fix corner case in query-replace-regexp undoTino Calancha1-0/+4
This commit fixes Bug#31492. * lisp/replace.el (replace-match-maybe-edit): Preserve match data. * test/lisp/replace-tests.el (query-replace-undo-bug31492): Add test.
2018-04-23Improve Isearch error handlingJuri Linkov1-1/+1
* lisp/isearch.el (isearch--momentary-message): Propertize message suffix with minibuffer-prompt face. (isearch--describe-regexp-mode): Do not omit description in case of error in default non-literal search. (isearch-message-prefix): Display “case-sensitive” in case of error. (isearch-message-suffix): Propertize message suffix with minibuffer-prompt face. (isearch-search-fun-default): Remove unused error handling. * lisp/vc/add-log.el (change-log-next-buffer): Better handle errors during wrapping.
2018-04-20* lisp/replace.el (query-replace-descr): Silence compiler.Glenn Morris1-2/+3
2018-04-19Use text properties to save search parameters. (Bug#22479)Juri Linkov1-7/+29
* lisp/isearch.el (isearch-update-ring): Call isearch-string-propertize. Delete duplicates with possibly different text properties. (isearch-string-propertize) (isearch-update-from-string-properties): New functions. (with-isearch-suspended, isearch-ring-adjust1): Call isearch-update-from-string-properties. (isearch-edit-string): Let-bind minibuffer-allow-text-properties to t. (isearch-query-replace): Use propertized isearch-string. (isearch--lax-regexp-function-p): Simplify. * lisp/replace.el (query-replace-descr): Rewrite to keep text properties non-destructively in the replacement string. (query-replace--split-string): Don't remove text properties by substring-no-properties. (query-replace-read-args): Try to get isearch-regexp-function from text-properties. (perform-replace): Display parameters in the replacement message. * lisp/desktop.el (desktop--v2s): Check if text properties are unreadable. (Bug#30786)
2018-04-19* lisp/isearch.el (isearch-mode-map): Restore advertised bindings.Juri Linkov1-1/+1
Remove obsolete comments and code. * lisp/replace.el (occur-find-match): Use user-error instead of error. (Bug#14912)
2018-04-19Add REGION-NONCONTIGUOUS-P arg to other replace.el commandsDrew Adams1-16/+37
* lisp/replace.el (query-replace, query-replace-regexp): Doc fix. (query-replace-regexp-eval, map-query-replace-regexp) (replace-string, replace-regexp): Add REGION-NONCONTIGUOUS-P arg. (perform-replace): Doc fix. (Bug#27897)
2018-04-17Use next-error-found to set next-error-last-buffer.Juri Linkov1-26/+23
https://lists.gnu.org/archive/html/emacs-devel/2018-04/msg00207.html * lisp/simple.el (next-error-buffer): New buffer-local variable instead of making buffer-local next-error-last-buffer. (Bug#20489) (next-error-found-function): New defcustom. (next-error-buffer-on-selected-frame): Use t for avoid-current arg of next-error-buffer-p. (next-error-find-buffer): Add second rule for using the current next-error-buffer if it's not visited by other navigation. (next-error, next-error-internal): Call next-error-found. (next-error-found): New function with body extracted mostly from next-error. * lisp/vc/add-log.el (change-log-goto-source-internal): New function with body from change-log-goto-source. (change-log-goto-source): Call change-log-goto-source-internal and next-error-found. (change-log-next-error): Call change-log-goto-source-internal instead of change-log-goto-source. (change-log-mode): Don't set next-error-last-buffer. (Bug#28864) * lisp/vc/diff-mode.el (diff-goto-source): Call next-error-found. * lisp/progmodes/xref.el (xref-goto-xref): Call next-error-found. * lisp/replace.el (occur-mode-goto-occurrence) (occur-mode-goto-occurrence-other-window) (occur-mode-display-occurrence): Call next-error-found. (occur-next-error): Remove unnecessary with-current-buffer. (Bug#27362, bug#30646)
2018-04-09Preserve case in query-replace undoTino Calancha1-0/+1
If the user query and replaces 'foo' with 'BAR', then undo must comeback to 'foo', not to 'FOO' (Bug#31073). * lisp/replace.el (perform-replace): Bind nocasify to non-nil value during undo/undo-all actions. * test/lisp/replace-tests.el (query-replace-undo-bug31073): Add test.
2018-02-06; Small fixes and indentationJuri Linkov1-20/+20
2018-02-06Support occur command operating on the region from Isearch.Juri Linkov1-6/+8
* lisp/isearch.el (isearch-occur): Use region-bounds as region arg of occur. (isearch-query-replace): Use use-region-p. * lisp/replace.el (occur--region-start-line): Rename from occur--matches-threshold. (occur): Use complete lines when region is active for line-oriented occur. (occur-engine): Count lines either from occur--region-start-line or 1.
2018-02-05Support list-matching-lines-jump-to-current-line for context lines.Juri Linkov1-47/+85
* lisp/replace.el (occur--orig-line-str): Remove. (occur): Remove occur--orig-line-str. (occur-engine): Use add-face-text-property to add the face list-matching-lines-current-line-face to the current line. Use previous-single-property-change to find occur--final-pos. (occur-context-lines): New args orig-line and multi-occur-p. Find the current line in context lines and add face to it. (Bug#30281)
2018-01-01Update copyright year to 2018Paul Eggert1-1/+1
Run admin/update-copyright.
2017-12-26Fix highlighting in query-replace with non-nil replace-char-foldCharles A. Roelli1-1/+4
* lisp/replace.el (replace-highlight): Bind 'isearch-regexp-function' in the same way that function 'replace-search' does, so as to respect the value of 'replace-char-fold'. (Bug#24356)
2017-11-18Fix case-folding in OccurEli Zaretskii1-168/+178
* lisp/replace.el (occur-engine): Bind case-fold-search in each buffer we search. (Bug#29254)
2017-10-25Fix autoload of flymake from elisp-mode during bootstrap (bug#28994)Stefan Monnier1-0/+1
* lisp/loadup.el: add `progmodes` to load-path so we can find flymake.el. * lisp/kmacro.el: Require `replace` since we use query-replace-map. * lisp/replace.el: Require `text-mode` since we use text-mode-map.
2017-09-13Prefer HTTPS to FTP and HTTP in documentationPaul Eggert1-1/+1
Most of this change is to boilerplate commentary such as license URLs. This change was prompted by ftp://ftp.gnu.org's going-away party, planned for November. Change these FTP URLs to https://ftp.gnu.org instead. Make similar changes for URLs to other organizations moving away from FTP. Also, change HTTP to HTTPS for URLs to gnu.org and fsf.org when this works, as this will further help defend against man-in-the-middle attacks (for this part I omitted the MS-DOS and MS-Windows sources and the test tarballs to keep the workload down). HTTPS is not fully working to lists.gnu.org so I left those URLs alone for now.