all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* patch to remove defadvice in complete.el
@ 2007-06-21 13:01 Sean O'Rourke
       [not found] ` <E1I2TH5-0001gm-OG@fencepost.gnu.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Sean O'Rourke @ 2007-06-21 13:01 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 170 bytes --]

Dan Nicolaescu brought to my attention the use of advice in
complete.el.  The attached patch removes it without (I think)
harming the include-file-expanding feature.

/s

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: noadvice.diff --]
[-- Type: text/x-patch, Size: 4224 bytes --]

diff -uw /usr/local/share/emacs/22.1.50/lisp/complete.el.\~1.72\~ /usr/local/share/emacs/22.1.50/lisp/complete.el
--- /usr/local/share/emacs/22.1.50/lisp/complete.el.~1.72~	2007-06-04 14:59:26.000000000 -0700
+++ /usr/local/share/emacs/22.1.50/lisp/complete.el	2007-06-20 18:44:18.000000000 -0700
@@ -231,13 +222,6 @@
 	 (remove-hook 'find-file-not-found-functions 'PC-look-for-include-file))
 	((not PC-disable-includes)
 	 (add-hook 'find-file-not-found-functions 'PC-look-for-include-file)))
-  ;; ... with some underhand redefining.
-  (cond ((not partial-completion-mode)
-         (ad-disable-advice 'read-file-name-internal 'around 'PC-include-file)
-         (ad-activate 'read-file-name-internal))
-	((not PC-disable-includes)
-         (ad-enable-advice 'read-file-name-internal 'around 'PC-include-file)
-         (ad-activate 'read-file-name-internal)))
   ;; Adjust the completion selection in *Completion* buffers to the way
   ;; we work.  The default minibuffer completion code only completes the
   ;; text before point and leaves the text after point alone (new in
@@ -439,7 +423,9 @@
 GOTO-END is non-nil, however, it instead replaces up to END."
   (or beg (setq beg (minibuffer-prompt-end)))
   (or end (setq end (point-max)))
-  (let* ((table minibuffer-completion-table)
+  (let* ((table (if (eq minibuffer-completion-table 'read-file-name-internal)
+                    'PC-read-file-name-internal
+                    minibuffer-completion-table))
 	 (pred minibuffer-completion-predicate)
 	 (filename (funcall PC-completion-as-file-name-predicate))
 	 (dirname nil) ; non-nil only if a filename is being completed
@@ -532,11 +519,11 @@
 		     (insert str)
 		     (setq end (+ beg (length str)))))
 	       (if origstr
-                   ;; If the wildcards were introduced by us, it's possible
-                   ;; that read-file-name-internal (especially our
-                   ;; PC-include-file advice) can still find matches for the
-                   ;; original string even if we couldn't, so remove the
-                   ;; added wildcards.
+                       ;; If the wildcards were introduced by us, it's
+                       ;; possible that PC-read-file-name-internal can
+                       ;; still find matches for the original string
+                       ;; even if we couldn't, so remove the added
+                       ;; wildcards.
                    (setq str origstr)
 		 (setq filename nil table nil pred nil)))))
 
@@ -921,7 +921,7 @@
 				       (point-min) t)
                    (+ (point) 2)
                    (point-min)))
-          (minibuffer-completion-table 'read-file-name-internal)
+          (minibuffer-completion-table 'PC-read-file-name-internal)
           (minibuffer-completion-predicate "")
           (PC-not-minibuffer t))
      (goto-char end)
@@ -1107,24 +1107,23 @@
 	  (setq sorted (cdr sorted)))
 	compressed))))
 
-(defadvice read-file-name-internal (around PC-include-file disable)
-  (if (string-match "<\\([^\"<>]*\\)>?\\'" (ad-get-arg 0))
-      (let* ((string (ad-get-arg 0))
-             (action (ad-get-arg 2))
-             (name (match-string 1 string))
+(defun PC-read-file-name-internal (string dir action)
+  "Extend `read-file-name-internal' to handle include files.
+This is only used by "
+  (if (string-match "<\\([^\"<>]*\\)>?\\'" string)
+      (let* ((name (match-string 1 string))
 	     (str2 (substring string (match-beginning 0)))
 	     (completion-table
 	      (mapcar (lambda (x)
                         (format (if (string-match "/\\'" x) "<%s" "<%s>") x))
 		      (PC-include-file-all-completions
 		       name (PC-include-file-path)))))
-        (setq ad-return-value
               (cond
                ((not completion-table) nil)
                ((eq action 'lambda) (test-completion str2 completion-table nil))
                ((eq action nil) (PC-try-completion str2 completion-table nil))
-               ((eq action t) (all-completions str2 completion-table nil)))))
-    ad-do-it))
+          ((eq action t) (all-completions str2 completion-table nil))))
+    (read-file-name-internal string dir action)))
 \f
 
 (provide 'complete)

Diff finished.  Wed Jun 20 19:17:51 2007

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: patch to remove defadvice in complete.el
       [not found] ` <E1I2TH5-0001gm-OG@fencepost.gnu.org>
@ 2007-06-26 16:57   ` Sean O'Rourke
  0 siblings, 0 replies; 2+ messages in thread
From: Sean O'Rourke @ 2007-06-26 16:57 UTC (permalink / raw)
  To: rms; +Cc: emacs-devel

Richard Stallman <rms@gnu.org> writes:

> Your change looks correct to me, and thanks for helping to get rid of
> a defadvice.  Can you send a change log entry for the change?

Sure.

2007-06-24  Sean O'Rourke  <sorourke@cs.ucsd.edu>

	* complete.el (partial-completion-mode): Remove advice of
	read-file-name-internal. 
	(PC-do-completion): Rebind minibuffer-completion-table.
	(PC-read-file-name-internal): New function doing what
	read-file-name-internal advice did.

/s

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-06-26 16:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-21 13:01 patch to remove defadvice in complete.el Sean O'Rourke
     [not found] ` <E1I2TH5-0001gm-OG@fencepost.gnu.org>
2007-06-26 16:57   ` Sean O'Rourke

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.