aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2013-09-13 10:56:03 -0400
committerStefan Monnier2013-09-13 10:56:03 -0400
commit7830899f39515bcb4938715ebf58d1ba855deb41 (patch)
treeb552f8044c183e01de30ba617dd8decca73292eb
parent84387cd2595e0e99bb6976fe1e160156b5291611 (diff)
downloademacs-7830899f39515bcb4938715ebf58d1ba855deb41.tar.gz
emacs-7830899f39515bcb4938715ebf58d1ba855deb41.zip
* 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.
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/ls-lisp.el23
2 files changed, 15 insertions, 16 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 93156233ee1..649e3a3b01c 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
12013-09-13 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * ls-lisp.el: Use advice-add.
4 (original-insert-directory): Remove.
5 (ls-lisp--insert-directory): Rename from insert-directory; add
6 `orig-fun' argument.
7 (insert-directory): Advise.
8
12013-09-13 Eli Zaretskii <eliz@gnu.org> 92013-09-13 Eli Zaretskii <eliz@gnu.org>
2 10
3 * term.el (term-emulate-terminal): Decode the command string 11 * term.el (term-emulate-terminal): Decode the command string
diff --git a/lisp/ls-lisp.el b/lisp/ls-lisp.el
index 82a78545d62..9ffbd2ccf56 100644
--- a/lisp/ls-lisp.el
+++ b/lisp/ls-lisp.el
@@ -198,9 +198,6 @@ to fail to line up, e.g. if month names are not all of the same length."
198 :type 'boolean 198 :type 'boolean
199 :group 'ls-lisp) 199 :group 'ls-lisp)
200 200
201(defvar original-insert-directory nil
202 "This holds the original function definition of `insert-directory'.")
203
204(defvar ls-lisp-uid-d-fmt "-%d" 201(defvar ls-lisp-uid-d-fmt "-%d"
205 "Format to display integer UIDs.") 202 "Format to display integer UIDs.")
206(defvar ls-lisp-uid-s-fmt "-%s" 203(defvar ls-lisp-uid-s-fmt "-%s"
@@ -213,15 +210,10 @@ to fail to line up, e.g. if month names are not all of the same length."
213 "Format to display integer file sizes.") 210 "Format to display integer file sizes.")
214(defvar ls-lisp-filesize-f-fmt "%.0f" 211(defvar ls-lisp-filesize-f-fmt "%.0f"
215 "Format to display float file sizes.") 212 "Format to display float file sizes.")
216
217;; Remember the original insert-directory function
218(or (featurep 'ls-lisp) ; FJW: unless this file is being reloaded!
219 (setq original-insert-directory (symbol-function 'insert-directory)))
220
221 213
222;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 214;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
223 215
224(defun insert-directory (file switches &optional wildcard full-directory-p) 216(defun ls-lisp--insert-directory (orig-fun file switches &optional wildcard full-directory-p)
225 "Insert directory listing for FILE, formatted according to SWITCHES. 217 "Insert directory listing for FILE, formatted according to SWITCHES.
226Leaves point after the inserted text. 218Leaves point after the inserted text.
227SWITCHES may be a string of options, or a list of strings. 219SWITCHES may be a string of options, or a list of strings.
@@ -231,12 +223,10 @@ switches do not contain `d', so that a full listing is expected.
231 223
232This version of the function comes from `ls-lisp.el'. 224This version of the function comes from `ls-lisp.el'.
233If the value of `ls-lisp-use-insert-directory-program' is non-nil then 225If the value of `ls-lisp-use-insert-directory-program' is non-nil then
234it works exactly like the version from `files.el' and runs a directory 226this advice just delegates the work to ORIG-FUN (the normal `insert-directory'
235listing program whose name is in the variable 227function from `files.el').
236`insert-directory-program'; if also WILDCARD is non-nil then it runs 228But if the value of `ls-lisp-use-insert-directory-program' is nil
237the shell specified by `shell-file-name'. If the value of 229then it runs a Lisp emulation.
238`ls-lisp-use-insert-directory-program' is nil then it runs a Lisp
239emulation.
240 230
241The Lisp emulation does not run any external programs or shells. It 231The Lisp emulation does not run any external programs or shells. It
242supports ordinary shell wildcards if `ls-lisp-support-shell-wildcards' 232supports ordinary shell wildcards if `ls-lisp-support-shell-wildcards'
@@ -245,7 +235,7 @@ to match file names. It does not support all `ls' switches -- those
245that work are: A a B C c F G g h i n R r S s t U u X. The l switch 235that work are: A a B C c F G g h i n R r S s t U u X. The l switch
246is assumed to be always present and cannot be turned off." 236is assumed to be always present and cannot be turned off."
247 (if ls-lisp-use-insert-directory-program 237 (if ls-lisp-use-insert-directory-program
248 (funcall original-insert-directory 238 (funcall orig-fun
249 file switches wildcard full-directory-p) 239 file switches wildcard full-directory-p)
250 ;; We need the directory in order to find the right handler. 240 ;; We need the directory in order to find the right handler.
251 (let ((handler (find-file-name-handler (expand-file-name file) 241 (let ((handler (find-file-name-handler (expand-file-name file)
@@ -305,6 +295,7 @@ is assumed to be always present and cannot be turned off."
305 (replace-match "total used in directory") 295 (replace-match "total used in directory")
306 (end-of-line) 296 (end-of-line)
307 (insert " available " available))))))))) 297 (insert " available " available)))))))))
298(advice-add 'insert-directory :around #'ls-lisp--insert-directory)
308 299
309(defun ls-lisp-insert-directory 300(defun ls-lisp-insert-directory
310 (file switches time-index wildcard-regexp full-directory-p) 301 (file switches time-index wildcard-regexp full-directory-p)