From: JUAN-LEON Lahoz Garcia <juanleon1@gmail.com>
Subject: patch to wdired.el to remove advising code
Date: Wed, 06 Apr 2005 12:20:03 +0200 [thread overview]
Message-ID: <m3r7ho6wbw.fsf@kaliban.madrid.ecid.cig.mot.com> (raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 5263 bytes --]
Hi,
wdired.el advise some functions (query-replace query-replace-regexp
replace-string) for avoiding problems with read-only portions of the
buffer.
But advising functions was not the right thing to do within packages
included in emacs, whenever it can be avoided.
Now, new emacs 22 variable query-replace-skip-read-only can be used
for avoinding this
Patch below removes all the advice-related code of wdired.el and set
this variable to t (after making it buffer local). Maybe any developer
here might want to review and/or apply it.
This patch also updates my email address (the old one was lost years
ago).
[ PS: I wonder if creating a variable `case-commands-skip-read-only'
would be useful for any other issue other that simplifiying
wdired. ]
[ PS2: Stefan, thanks for taking the time to including wdired here ]
Regards
juanleon
--- wdired.el.~1.6.~ Fri Feb 18 08:08:18 2005
+++ wdired.el Wed Apr 6 12:06:01 2005
@@ -3,8 +3,8 @@
;; Copyright (C) 2001, 2004 Free Software Foundation, Inc.
;; Filename: wdired.el
-;; Author: Juan León Lahoz García <juan-leon.lahoz@tecsidel.es>
-;; Version: 1.91
+;; Author: Juan León Lahoz García <juanleon1@gmail.com>
+;; Version: 2.0
;; Keywords: dired, environment, files, renaming
;; This file is part of GNU Emacs.
@@ -157,7 +157,6 @@
;;; Code:
(eval-when-compile
- (require 'advice)
(defvar dired-backup-overwrite) ; Only in emacs 20.x this is a custom var
(set (make-local-variable 'byte-compile-dynamic) t))
@@ -199,19 +198,6 @@
(other :tag "As in dired mode" t))
:group 'wdired)
-(defcustom wdired-advise-functions t
- "*If t some editing commands are advised when wdired is loaded.
-The advice only has effect in wdired mode. These commands are
-`query-replace' `query-replace-regexp' `replace-string', and the
-advice makes them to ignore read-only regions, so no attempts to
-modify these regions are done by them, and so they don't end
-prematurely.
-
-Setting this to nil does not unadvise the functions, if they are
-already advised, but new Emacs will not advise them."
- :type 'boolean
- :group 'wdired)
-
(defcustom wdired-allow-to-redirect-links t
"*If non-nil, the target of the symbolic links can be changed also.
In systems without symbolic links support, this variable has no effect
@@ -309,6 +295,7 @@
(interactive)
(set (make-local-variable 'wdired-old-content)
(buffer-substring (point-min) (point-max)))
+ (set (make-local-variable 'query-replace-skip-read-only) t)
(use-local-map wdired-mode-map)
(force-mode-line-update)
(setq buffer-read-only nil)
@@ -662,64 +649,6 @@
Like original function but it skips read-only words."
(interactive "p")
(wdired-xcase-word 'capitalize-word arg))
-
-;; The following code is related to advice some interactive functions
-;; to make some editing commands in wdired mode not to fail trying to
-;; change read-only text. Notice that some advises advice and unadvise
-;; them-self to another functions: search-forward and
-;; re-search-forward. This is to keep these functions advised only
-;; when is necessary. Since they are built-in commands used heavily in
-;; lots of places, to have it permanently advised would cause some
-;; performance loss.
-
-
-(defun wdired-add-skip-in-replace (command)
- "Advice COMMAND to skip matches while they have read-only properties.
-This is useful to avoid \"read-only\" errors in search and replace
-commands. This advice only has effect in wdired mode."
- (eval
- `(defadvice ,command (around wdired-discard-read-only activate)
- ,(format "Make %s to work better with wdired,\n%s." command
- "skipping read-only matches when invoked without argument")
- ad-do-it
- (if (eq major-mode 'wdired-mode)
- (while (and ad-return-value
- (text-property-any
- (max 1 (1- (match-beginning 0))) (match-end 0)
- 'read-only t))
- ad-do-it))
- ad-return-value)))
-
-
-(defun wdired-add-replace-advice (command)
- "Advice COMMAND to skip matches while they have read-only properties.
-This is useful to avoid \"read-only\" errors in search and replace
-commands. This advice only has effect in wdired mode."
- (eval
- `(defadvice ,command (around wdired-grok-read-only activate)
- ,(format "Make %s to work better with wdired,\n%s." command
- "skipping read-only matches when invoked without argument")
- (if (eq major-mode 'wdired-mode)
- (progn
- (wdired-add-skip-in-replace 'search-forward)
- (wdired-add-skip-in-replace 're-search-forward)
- (unwind-protect
- ad-do-it
- (progn
- (ad-remove-advice 'search-forward
- 'around 'wdired-discard-read-only)
- (ad-remove-advice 're-search-forward
- 'around 'wdired-discard-read-only)
- (ad-update 'search-forward)
- (ad-update 're-search-forward))))
- ad-do-it)
- ad-return-value)))
-
-
-(if wdired-advise-functions
- (progn
- (mapcar 'wdired-add-replace-advice
- '(query-replace query-replace-regexp replace-string))))
;; The following code deals with changing the access bits (or
next reply other threads:[~2005-04-06 10:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-06 10:20 JUAN-LEON Lahoz Garcia [this message]
2005-04-06 11:58 ` patch to wdired.el to remove advising code Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3r7ho6wbw.fsf@kaliban.madrid.ecid.cig.mot.com \
--to=juanleon1@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).