diff options
| author | Stefan Monnier | 2005-04-06 11:57:03 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2005-04-06 11:57:03 +0000 |
| commit | 969ee2ad136f21df90f9f0fc0271776e16f4a0eb (patch) | |
| tree | 9ceb2bb1c867e2ed01640256fc69f326849b651b | |
| parent | f17387d3f4b0ff168b382fbd0359f10a317627ee (diff) | |
| download | emacs-969ee2ad136f21df90f9f0fc0271776e16f4a0eb.tar.gz emacs-969ee2ad136f21df90f9f0fc0271776e16f4a0eb.zip | |
(wdired-advise-functions, wdired-add-skip-in-replace)
(wdired-add-replace-advice): Remove.
(wdired-change-to-wdired-mode): Use query-replace-skip-read-only.
| -rw-r--r-- | lisp/ChangeLog | 24 | ||||
| -rw-r--r-- | lisp/wdired.el | 81 |
2 files changed, 20 insertions, 85 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 388e9a03987..a63f0cb1e85 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2005-04-06 JUAN-LEON Lahoz Garcia <juanleon1@gmail.com> | ||
| 2 | |||
| 3 | * wdired.el (wdired-advise-functions, wdired-add-skip-in-replace) | ||
| 4 | (wdired-add-replace-advice): Remove. | ||
| 5 | (wdired-change-to-wdired-mode): Use query-replace-skip-read-only. | ||
| 6 | |||
| 1 | 2005-04-06 Kim F. Storm <storm@cua.dk> | 7 | 2005-04-06 Kim F. Storm <storm@cua.dk> |
| 2 | 8 | ||
| 3 | * startup.el (command-line): Add --bare-bones alias for -Q. | 9 | * startup.el (command-line): Add --bare-bones alias for -Q. |
| @@ -21,8 +27,8 @@ | |||
| 21 | * generic.el (generic-mode-internal): Fix 2005-03-31 change. | 27 | * generic.el (generic-mode-internal): Fix 2005-03-31 change. |
| 22 | (define-generic-mode): Ditto. Fix debug declaration. | 28 | (define-generic-mode): Ditto. Fix debug declaration. |
| 23 | 29 | ||
| 24 | * generic-x.el (show-tabs-tab-face, show-tabs-space-face): Put | 30 | * generic-x.el (show-tabs-tab-face, show-tabs-space-face): |
| 25 | them in the generic-x group. | 31 | Put them in the generic-x group. |
| 26 | 32 | ||
| 27 | * calendar/timeclock.el (timeclock): Doc fix. | 33 | * calendar/timeclock.el (timeclock): Doc fix. |
| 28 | 34 | ||
| @@ -80,8 +86,8 @@ | |||
| 80 | 86 | ||
| 81 | 2005-04-04 Carsten Dominik <dominik@science.uva.nl> | 87 | 2005-04-04 Carsten Dominik <dominik@science.uva.nl> |
| 82 | 88 | ||
| 83 | * textmodes/org.el (org-insert-mode-line-in-empty-file): Change | 89 | * textmodes/org.el (org-insert-mode-line-in-empty-file): |
| 84 | default value to nil. | 90 | Change default value to nil. |
| 85 | 91 | ||
| 86 | 2005-04-04 Lute Kamstra <lute@gnu.org> | 92 | 2005-04-04 Lute Kamstra <lute@gnu.org> |
| 87 | 93 | ||
| @@ -135,11 +141,11 @@ | |||
| 135 | 141 | ||
| 136 | 2005-04-03 Marcelo Toledo <marcelo@marcelotoledo.org> | 142 | 2005-04-03 Marcelo Toledo <marcelo@marcelotoledo.org> |
| 137 | 143 | ||
| 138 | * add-log.el (change-log-font-lock-keywords): The manual | 144 | * add-log.el (change-log-font-lock-keywords): The manual |
| 139 | describing a Change Log entry, says: (...) "Aside from these | 145 | describing a Change Log entry, says: (...) "Aside from these |
| 140 | header lines, every line in the change log starts with a space or | 146 | header lines, every line in the change log starts with a space or |
| 141 | a tab.". The font-lock was not highlighting lines started with | 147 | a tab.". The font-lock was not highlighting lines started with |
| 142 | spaces, added support for it. | 148 | spaces, added support for it. |
| 143 | 149 | ||
| 144 | 2005-04-03 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de> | 150 | 2005-04-03 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de> |
| 145 | 151 | ||
diff --git a/lisp/wdired.el b/lisp/wdired.el index a4119343600..4b37bc33659 100644 --- a/lisp/wdired.el +++ b/lisp/wdired.el | |||
| @@ -1,10 +1,10 @@ | |||
| 1 | ;;; wdired.el --- Rename files editing their names in dired buffers | 1 | ;;; wdired.el --- Rename files editing their names in dired buffers |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 2001, 2004 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 2001, 2004, 2005 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Filename: wdired.el | 5 | ;; Filename: wdired.el |
| 6 | ;; Author: Juan León Lahoz García <juan-leon.lahoz@tecsidel.es> | 6 | ;; Author: Juan León Lahoz García <juanleon1@gmail.com> |
| 7 | ;; Version: 1.91 | 7 | ;; Version: 2.0 |
| 8 | ;; Keywords: dired, environment, files, renaming | 8 | ;; Keywords: dired, environment, files, renaming |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| @@ -156,9 +156,8 @@ | |||
| 156 | 156 | ||
| 157 | ;;; Code: | 157 | ;;; Code: |
| 158 | 158 | ||
| 159 | (defvar dired-backup-overwrite) ; Only in emacs 20.x this is a custom var | ||
| 159 | (eval-when-compile | 160 | (eval-when-compile |
| 160 | (require 'advice) | ||
| 161 | (defvar dired-backup-overwrite) ; Only in emacs 20.x this is a custom var | ||
| 162 | (set (make-local-variable 'byte-compile-dynamic) t)) | 161 | (set (make-local-variable 'byte-compile-dynamic) t)) |
| 163 | 162 | ||
| 164 | (eval-and-compile | 163 | (eval-and-compile |
| @@ -199,19 +198,6 @@ If nil, \"up\" and \"down\" movement is done as in any other buffer." | |||
| 199 | (other :tag "As in dired mode" t)) | 198 | (other :tag "As in dired mode" t)) |
| 200 | :group 'wdired) | 199 | :group 'wdired) |
| 201 | 200 | ||
| 202 | (defcustom wdired-advise-functions t | ||
| 203 | "*If t some editing commands are advised when wdired is loaded. | ||
| 204 | The advice only has effect in wdired mode. These commands are | ||
| 205 | `query-replace' `query-replace-regexp' `replace-string', and the | ||
| 206 | advice makes them to ignore read-only regions, so no attempts to | ||
| 207 | modify these regions are done by them, and so they don't end | ||
| 208 | prematurely. | ||
| 209 | |||
| 210 | Setting this to nil does not unadvise the functions, if they are | ||
| 211 | already advised, but new Emacs will not advise them." | ||
| 212 | :type 'boolean | ||
| 213 | :group 'wdired) | ||
| 214 | |||
| 215 | (defcustom wdired-allow-to-redirect-links t | 201 | (defcustom wdired-allow-to-redirect-links t |
| 216 | "*If non-nil, the target of the symbolic links can be changed also. | 202 | "*If non-nil, the target of the symbolic links can be changed also. |
| 217 | In systems without symbolic links support, this variable has no effect | 203 | In systems without symbolic links support, this variable has no effect |
| @@ -309,6 +295,7 @@ See `wdired-mode'." | |||
| 309 | (interactive) | 295 | (interactive) |
| 310 | (set (make-local-variable 'wdired-old-content) | 296 | (set (make-local-variable 'wdired-old-content) |
| 311 | (buffer-substring (point-min) (point-max))) | 297 | (buffer-substring (point-min) (point-max))) |
| 298 | (set (make-local-variable 'query-replace-skip-read-only) t) | ||
| 312 | (use-local-map wdired-mode-map) | 299 | (use-local-map wdired-mode-map) |
| 313 | (force-mode-line-update) | 300 | (force-mode-line-update) |
| 314 | (setq buffer-read-only nil) | 301 | (setq buffer-read-only nil) |
| @@ -664,64 +651,6 @@ Like original function but it skips read-only words." | |||
| 664 | (interactive "p") | 651 | (interactive "p") |
| 665 | (wdired-xcase-word 'capitalize-word arg)) | 652 | (wdired-xcase-word 'capitalize-word arg)) |
| 666 | 653 | ||
| 667 | ;; The following code is related to advice some interactive functions | ||
| 668 | ;; to make some editing commands in wdired mode not to fail trying to | ||
| 669 | ;; change read-only text. Notice that some advises advice and unadvise | ||
| 670 | ;; them-self to another functions: search-forward and | ||
| 671 | ;; re-search-forward. This is to keep these functions advised only | ||
| 672 | ;; when is necessary. Since they are built-in commands used heavily in | ||
| 673 | ;; lots of places, to have it permanently advised would cause some | ||
| 674 | ;; performance loss. | ||
| 675 | |||
| 676 | |||
| 677 | (defun wdired-add-skip-in-replace (command) | ||
| 678 | "Advice COMMAND to skip matches while they have read-only properties. | ||
| 679 | This is useful to avoid \"read-only\" errors in search and replace | ||
| 680 | commands. This advice only has effect in wdired mode." | ||
| 681 | (eval | ||
| 682 | `(defadvice ,command (around wdired-discard-read-only activate) | ||
| 683 | ,(format "Make %s to work better with wdired,\n%s." command | ||
| 684 | "skipping read-only matches when invoked without argument") | ||
| 685 | ad-do-it | ||
| 686 | (if (eq major-mode 'wdired-mode) | ||
| 687 | (while (and ad-return-value | ||
| 688 | (text-property-any | ||
| 689 | (max 1 (1- (match-beginning 0))) (match-end 0) | ||
| 690 | 'read-only t)) | ||
| 691 | ad-do-it)) | ||
| 692 | ad-return-value))) | ||
| 693 | |||
| 694 | |||
| 695 | (defun wdired-add-replace-advice (command) | ||
| 696 | "Advice COMMAND to skip matches while they have read-only properties. | ||
| 697 | This is useful to avoid \"read-only\" errors in search and replace | ||
| 698 | commands. This advice only has effect in wdired mode." | ||
| 699 | (eval | ||
| 700 | `(defadvice ,command (around wdired-grok-read-only activate) | ||
| 701 | ,(format "Make %s to work better with wdired,\n%s." command | ||
| 702 | "skipping read-only matches when invoked without argument") | ||
| 703 | (if (eq major-mode 'wdired-mode) | ||
| 704 | (progn | ||
| 705 | (wdired-add-skip-in-replace 'search-forward) | ||
| 706 | (wdired-add-skip-in-replace 're-search-forward) | ||
| 707 | (unwind-protect | ||
| 708 | ad-do-it | ||
| 709 | (progn | ||
| 710 | (ad-remove-advice 'search-forward | ||
| 711 | 'around 'wdired-discard-read-only) | ||
| 712 | (ad-remove-advice 're-search-forward | ||
| 713 | 'around 'wdired-discard-read-only) | ||
| 714 | (ad-update 'search-forward) | ||
| 715 | (ad-update 're-search-forward)))) | ||
| 716 | ad-do-it) | ||
| 717 | ad-return-value))) | ||
| 718 | |||
| 719 | |||
| 720 | (if wdired-advise-functions | ||
| 721 | (progn | ||
| 722 | (mapcar 'wdired-add-replace-advice | ||
| 723 | '(query-replace query-replace-regexp replace-string)))) | ||
| 724 | |||
| 725 | 654 | ||
| 726 | ;; The following code deals with changing the access bits (or | 655 | ;; The following code deals with changing the access bits (or |
| 727 | ;; permissions) of the files. | 656 | ;; permissions) of the files. |