diff options
| author | Stefan Monnier | 2013-09-13 10:56:03 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2013-09-13 10:56:03 -0400 |
| commit | 7830899f39515bcb4938715ebf58d1ba855deb41 (patch) | |
| tree | b552f8044c183e01de30ba617dd8decca73292eb | |
| parent | 84387cd2595e0e99bb6976fe1e160156b5291611 (diff) | |
| download | emacs-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/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/ls-lisp.el | 23 |
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 @@ | |||
| 1 | 2013-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 | |||
| 1 | 2013-09-13 Eli Zaretskii <eliz@gnu.org> | 9 | 2013-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. |
| 226 | Leaves point after the inserted text. | 218 | Leaves point after the inserted text. |
| 227 | SWITCHES may be a string of options, or a list of strings. | 219 | SWITCHES 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 | ||
| 232 | This version of the function comes from `ls-lisp.el'. | 224 | This version of the function comes from `ls-lisp.el'. |
| 233 | If the value of `ls-lisp-use-insert-directory-program' is non-nil then | 225 | If the value of `ls-lisp-use-insert-directory-program' is non-nil then |
| 234 | it works exactly like the version from `files.el' and runs a directory | 226 | this advice just delegates the work to ORIG-FUN (the normal `insert-directory' |
| 235 | listing program whose name is in the variable | 227 | function from `files.el'). |
| 236 | `insert-directory-program'; if also WILDCARD is non-nil then it runs | 228 | But if the value of `ls-lisp-use-insert-directory-program' is nil |
| 237 | the shell specified by `shell-file-name'. If the value of | 229 | then it runs a Lisp emulation. |
| 238 | `ls-lisp-use-insert-directory-program' is nil then it runs a Lisp | ||
| 239 | emulation. | ||
| 240 | 230 | ||
| 241 | The Lisp emulation does not run any external programs or shells. It | 231 | The Lisp emulation does not run any external programs or shells. It |
| 242 | supports ordinary shell wildcards if `ls-lisp-support-shell-wildcards' | 232 | supports 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 | |||
| 245 | 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 | 235 | 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 |
| 246 | is assumed to be always present and cannot be turned off." | 236 | is 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) |