emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r114270: * lisp/ls-lisp.el: Use advice-add.


From: Stefan Monnier
Subject: [Emacs-diffs] trunk r114270: * lisp/ls-lisp.el: Use advice-add.
Date: Fri, 13 Sep 2013 14:56:08 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 114270
revision-id: address@hidden
parent: address@hidden
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Fri 2013-09-13 10:56:03 -0400
message:
  * lisp/ls-lisp.el: Use advice-add.
  (original-insert-directory): Remove.
  (ls-lisp--insert-directory): Rename from insert-directory; add
  `orig-fun' argument.
  (insert-directory): Advise.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/ls-lisp.el                lslisp.el-20091113204419-o5vbwnq5f7feedwu-191
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-09-13 13:22:47 +0000
+++ b/lisp/ChangeLog    2013-09-13 14:56:03 +0000
@@ -1,3 +1,11 @@
+2013-09-13  Stefan Monnier  <address@hidden>
+
+       * ls-lisp.el: Use advice-add.
+       (original-insert-directory): Remove.
+       (ls-lisp--insert-directory): Rename from insert-directory; add
+       `orig-fun' argument.
+       (insert-directory): Advise.
+
 2013-09-13  Eli Zaretskii  <address@hidden>
 
        * term.el (term-emulate-terminal): Decode the command string

=== modified file 'lisp/ls-lisp.el'
--- a/lisp/ls-lisp.el   2013-05-05 05:03:08 +0000
+++ b/lisp/ls-lisp.el   2013-09-13 14:56:03 +0000
@@ -198,9 +198,6 @@
   :type 'boolean
   :group 'ls-lisp)
 
-(defvar original-insert-directory nil
-  "This holds the original function definition of `insert-directory'.")
-
 (defvar ls-lisp-uid-d-fmt "-%d"
   "Format to display integer UIDs.")
 (defvar ls-lisp-uid-s-fmt "-%s"
@@ -213,15 +210,10 @@
   "Format to display integer file sizes.")
 (defvar ls-lisp-filesize-f-fmt "%.0f"
   "Format to display float file sizes.")
-
-;; Remember the original insert-directory function
-(or (featurep 'ls-lisp)  ; FJW: unless this file is being reloaded!
-    (setq original-insert-directory (symbol-function 'insert-directory)))
-
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-(defun insert-directory (file switches &optional wildcard full-directory-p)
+(defun ls-lisp--insert-directory (orig-fun file switches &optional wildcard 
full-directory-p)
   "Insert directory listing for FILE, formatted according to SWITCHES.
 Leaves point after the inserted text.
 SWITCHES may be a string of options, or a list of strings.
@@ -231,12 +223,10 @@
 
 This version of the function comes from `ls-lisp.el'.
 If the value of `ls-lisp-use-insert-directory-program' is non-nil then
-it works exactly like the version from `files.el' and runs a directory
-listing program whose name is in the variable
-`insert-directory-program'; if also WILDCARD is non-nil then it runs
-the shell specified by `shell-file-name'.  If the value of
-`ls-lisp-use-insert-directory-program' is nil then it runs a Lisp
-emulation.
+this advice just delegates the work to ORIG-FUN (the normal `insert-directory'
+function from `files.el').
+But if the value of `ls-lisp-use-insert-directory-program' is nil
+then it runs a Lisp emulation.
 
 The Lisp emulation does not run any external programs or shells.  It
 supports ordinary shell wildcards if `ls-lisp-support-shell-wildcards'
@@ -245,7 +235,7 @@
 that work are: A a B C c F G g h i n R r S s t U u X.  The l switch
 is assumed to be always present and cannot be turned off."
   (if ls-lisp-use-insert-directory-program
-      (funcall original-insert-directory
+      (funcall orig-fun
               file switches wildcard full-directory-p)
     ;; We need the directory in order to find the right handler.
     (let ((handler (find-file-name-handler (expand-file-name file)
@@ -305,6 +295,7 @@
                (replace-match "total used in directory")
                (end-of-line)
                (insert " available " available)))))))))
+(advice-add 'insert-directory :around #'ls-lisp--insert-directory)
 
 (defun ls-lisp-insert-directory
   (file switches time-index wildcard-regexp full-directory-p)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]