summaryrefslogtreecommitdiff
path: root/lisp/replace.el
Commit message (Collapse)AuthorAgeFilesLines
* Inhibit displaying help buffer in main window in perform-replaceJuri Linkov2019-04-101-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
* i18n: Add function ngettext for pluralization.Juri Linkov2019-03-241-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".
* * lisp/replace.el (flush-lines): Return the number of deleted lines.Juri Linkov2019-02-281-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.
* Merge from origin/emacs-26Paul Eggert2018-12-311-1/+1
|\ | | | | | | | | | | 2fcf2df Fix copyright years by hand 26bed8b Update copyright year to 2019 2814292 Fix value of default frame height. (Bug#33921)
| * Update copyright year to 2019Paul Eggert2019-01-011-1/+1
| | | | | | | | Run 'TZ=UTC0 admin/update-copyright $(git ls-files)'.
| * Guard occur against an undefined orig-lineRaimon Grau2018-12-101-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)
| * query-replace undo: Handle when user edits the replacement stringTino Calancha2018-06-031-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)
| * Backport: Fix corner case in query-replace-regexp undoTino Calancha2018-06-031-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)
| * Backport: Preserve case in query-replace undoTino Calancha2018-06-031-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)
* | More font-lock improvements for diff-modeJuri Linkov2018-12-191-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.
* | Fix occur for non-nil list-matching-lines-jump-to-current-line (bug#33476)Juri Linkov2018-12-101-6/+6
| | | | | | | | | | * lisp/replace.el (occur-engine): Move orig-line let-binding higher. Don't use start-line in forward-line.
* | * lisp/replace.el (occur--garbage-collect-revert-args): New functionStefan Monnier2018-10-091-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.
* | Revert part of last commitEli Zaretskii2018-10-091-13/+1
| | | | | | | | | | * lisp/replace.el (occur-revert-function): Revert last change, as it's no longer needed. (Bug#32987)
* | Merge branch 'master' of git.savannah.gnu.org:/srv/git/emacsEli Zaretskii2018-10-091-99/+91
|\ \
| * | * lisp/replace.el: Rework implementation of the occur regionStefan Monnier2018-10-091-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.
* | | Unbreak 'revert-buffer' in Occur buffersEli Zaretskii2018-10-091-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.
* | Fix a previous commitTino Calancha2018-09-211-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.
* | Fix bug 32543Tino Calancha2018-09-181-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.
* | query-replace undo: Handle when user edits the replacement stringTino Calancha2018-05-261-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.
* | Fix corner case in query-replace-regexp undoTino Calancha2018-05-231-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.
* | Improve Isearch error handlingJuri Linkov2018-04-231-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.
* | * lisp/replace.el (query-replace-descr): Silence compiler.Glenn Morris2018-04-201-2/+3
| |
* | Use text properties to save search parameters. (Bug#22479)Juri Linkov2018-04-191-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)
* | * lisp/isearch.el (isearch-mode-map): Restore advertised bindings.Juri Linkov2018-04-191-1/+1
| | | | | | | | | | | | | | Remove obsolete comments and code. * lisp/replace.el (occur-find-match): Use user-error instead of error. (Bug#14912)
* | Add REGION-NONCONTIGUOUS-P arg to other replace.el commandsDrew Adams2018-04-191-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)
* | Use next-error-found to set next-error-last-buffer.Juri Linkov2018-04-171-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)
* | Preserve case in query-replace undoTino Calancha2018-04-091-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.
* | ; Small fixes and indentationJuri Linkov2018-02-061-20/+20
| |
* | Support occur command operating on the region from Isearch.Juri Linkov2018-02-061-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.
* | Support list-matching-lines-jump-to-current-line for context lines.Juri Linkov2018-02-051-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)
* | Merge from origin/emacs-26Paul Eggert2018-01-011-1/+1
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 63b04c11d5 Fix copyright years by hand 5c7dd8a783 Update copyright year to 2018 220a9ecba1 Merge from Gnulib 312c565566 Don't add empty keyboard macro to macro ring (Bug#24992) 39ca289a7a Allow customization of decoding of "man" command f8240815ea * etc/NEWS: Add security consideration note on passphrase ... 0c78822c70 Fix subtle problem with scroll-down when scroll-margin is ... acd289c5a4 Fix problems with indexing in User manual b240c7846b * lisp/help.el (describe-key): Only (copy-sequence elt) wh... e879a5444a * src/buffer.c (Frestore_buffer_modified_p): Fix bug#29846 81b1028b63 Improve documentation of 'inhibit-modification-hooks' and ... 7175496d7a Fix doc string of 'enable-recursive-minibuffers' 5b38406491 Fix documentation of delsel and of killing text # Conflicts: # etc/NEWS # etc/refcards/ru-refcard.tex
| * Update copyright year to 2018Paul Eggert2018-01-011-1/+1
| | | | | | | | Run admin/update-copyright.
* | Fix highlighting in query-replace with non-nil replace-char-foldCharles A. Roelli2017-12-261-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)
* Fix case-folding in OccurEli Zaretskii2017-11-181-168/+178
| | | | | * lisp/replace.el (occur-engine): Bind case-fold-search in each buffer we search. (Bug#29254)
* Fix autoload of flymake from elisp-mode during bootstrap (bug#28994)Stefan Monnier2017-10-251-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.
* Prefer HTTPS to FTP and HTTP in documentationPaul Eggert2017-09-131-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.
* query-replace: Undo replacements performed with 'commaTino Calancha2017-08-081-28/+42
| | | | | | | | | | During a `query-replace', the char ',' replaces the character at point and doesn't move point; right after, the char 'u' must undo such replacement (Bug#27268). * lisp/replace.el (replace--push-stack): New macro extracted from `perform-replace'. (perform-replace): Use it. * test/lisp/replace-tests.el (query-replace--undo): Add test.
* Improve documentation of 'occur'Eli Zaretskii2017-07-291-0/+5
| | | | | | * doc/emacs/search.texi (Other Repeating Search): * lisp/replace.el (occur): Make the documentation of 'occur' be more accurate when matches overlap. (Bug#27818)
* * lisp/replace.el (query-replace-regexp-eval): Doc fix.Eli Zaretskii2017-05-191-2/+2
|
* ; * lisp/replace.el (query-replace-regexp, replace-regexp): Doc fixes.Eli Zaretskii2017-05-061-6/+7
|
* ; * lisp/replace.el (how-many, flush-lines, keep-lines): Remove empty line.Tino Calancha2017-04-021-3/+0
|
* Put text properties on query-replace separator string instead of "\0"Juri Linkov2017-02-281-14/+20
| | | | | | | * lisp/replace.el (query-replace--split-string): Split at a substring instead of just character. (query-replace-read-from): Put text properties on the separator string instead of "\0". (Bug#25482)
* * lisp/replace.el (query-replace-from-to-separator): Move propertizeJuri Linkov2017-02-131-17/+23
| | | | | | | | | | | | and char-displayable-p test to query-replace-read-from. Add choice nil to disable this feature. (query-replace-read-from): Don't reevaluate custom setting. Use char-displayable-p to test the first non-whitespace character in query-replace-from-to-separator, use " -> " when fails. Add prompt for the case when separator is nil but query-replace-defaults is non-nil. Remove unused test for regexp-flag. Thanks to Thierry Volpiatto <thierry.volpiatto@gmail.com>
* Show current line highlighted in *Occur* bufferTino Calancha2017-02-021-5/+67
| | | | | | | | | | | | | * lisp/replace.el (list-matching-lines-current-line-face) (list-matching-lines-jump-to-current-line): New user options. (occur--orig-line, occur--orig-line-str): New variables. (occur, occur-engine): Use them. (occur--final-pos): New variable. (occur-1): Use it. (occur-engine): Idem. Show the current line with 'list-matching-lines-current-line-face'. Set point on the first matching line after the current one. * etc/NEWS: Add entry for the new option.
* Allow occur command to operate on the regionTino Calancha2017-02-021-7/+40
| | | | | | | | | | | | | See discussion in: https://lists.gnu.org/archive/html/emacs-devel/2016-12/msg01084.html * lisp/replace.el (occur--region-start, occur--region-end) (occur--matches-threshold): New variables. (occur-engine): Use them. (occur): Idem. Add optional arg REGION; if non-nil occur applies in that region. * doc/lispintro/emacs-lisp-intro.texi (Keybindings): Update manual * doc/emacs/search.texi (Other Repeating Search): Idem. ; etc/NEWS: Add entry for the new feature.
* Merge from origin/emacs-25Paul Eggert2017-01-011-1/+1
|\ | | | | | | | | 2e2a806 Fix copyright years by hand 5badc81 Update copyright year to 2017
| * Update copyright year to 2017Paul Eggert2016-12-311-1/+1
| | | | | | | | Run admin/update-copyright.
* | Add missing 'provide's in preloaded packagesPhilippe Vaucher2016-11-251-0/+2
| | | | | | | | | | | | * lisp/composite.el: * lisp/replace.el: * lisp/textmodes/text-mode.el: Add provide statement. (Bug#24985)
* | Prescribe history for read-regexp in query-replaceMark Oteiza2016-11-071-1/+1
| | | | | | | | | | | | | | | | In the fix for bug#24580, the history argument for read-regexp was removed erroneously; read-regexp's history argument defaults to regexp-history, not minibuffer-history. * lisp/replace.el (query-replace-read-from): Tell read-regexp to use minibuffer-history. Fixes bug#24873.
* | Avoid dynamic binding on a symbolMark Oteiza2016-10-041-4/+4
| | | | | | | | | | | | | | | | Instead, bind history in the default minibuffer-history. Fixes bug#24580. * lisp/replace.el (query-replace-read-from): Let-bind minibuffer-history. Change read-regexp and read-from-minibuffer's HISTORY arguments to nil so that they use minibuffer-history.