# HG changeset patch # User Stefan Monnier # Date 1259427990 0 # Node ID 3a4157b5e53631a15a58205c37786289ca919dcb # Parent 42172f6a7f38f3853cd477678311f88265f87023 * eshell/em-prompt.el (eshell-prompt-function): Abbreviate pwd, since `cd' doesn't always do it for us (bug#5067). * pcomplete.el (pcomplete-entries): Revert change installed mistakenly on 2009-10-25 as part of some other change (bug#5067). diff -r 42172f6a7f38 -r 3a4157b5e536 lisp/ChangeLog --- a/lisp/ChangeLog Sat Nov 28 10:50:31 2009 +0000 +++ b/lisp/ChangeLog Sat Nov 28 17:06:30 2009 +0000 @@ -1,3 +1,11 @@ +2009-11-28 Stefan Monnier + + * eshell/em-prompt.el (eshell-prompt-function): Abbreviate pwd, since + `cd' doesn't always do it for us (bug#5067). + + * pcomplete.el (pcomplete-entries): Revert change installed mistakenly + on 2009-10-25 as part of some other change (bug#5067). + 2009-11-27 Stefan Monnier * emacs-lisp/bytecomp.el (byte-compile-warning-types): New type diff -r 42172f6a7f38 -r 3a4157b5e536 lisp/eshell/em-prompt.el --- a/lisp/eshell/em-prompt.el Sat Nov 28 10:50:31 2009 +0000 +++ b/lisp/eshell/em-prompt.el Sat Nov 28 17:06:30 2009 +0000 @@ -46,9 +46,9 @@ (defcustom eshell-prompt-function (function (lambda () - (concat (eshell/pwd) + (concat (abbreviate-file-name (eshell/pwd)) (if (= (user-uid) 0) " # " " $ ")))) - "*A function that returns the Eshell prompt string. + "A function that returns the Eshell prompt string. Make sure to update `eshell-prompt-regexp' so that it will match your prompt." :type 'function diff -r 42172f6a7f38 -r 3a4157b5e536 lisp/pcomplete.el --- a/lisp/pcomplete.el Sat Nov 28 10:50:31 2009 +0000 +++ b/lisp/pcomplete.el Sat Nov 28 17:06:30 2009 +0000 @@ -891,46 +891,65 @@ \(files for which the PREDICATE returns nil will be excluded). If no directory information can be extracted from the completed component, `default-directory' is used as the basis for completion." - ;; FIXME: obey pcomplete-file-ignore and pcomplete-dir-ignore. - ;; FIXME: obey pcomplete-compare-entry-function (tho only if there - ;; are less than pcomplete-cycle-cutoff-length completions). - ;; FIXME: expand envvars? shouldn't this be done globally instead? - (let* ((reg-pred (when regexp - (lexical-let ((re regexp)) - (lambda (f) - ;; (let ((name (file-name-nondirectory f))) - ;; (if (zerop (length name)) - ;; (setq name (file-name-as-directory - ;; (file-name-nondirectory - ;; (directory-file-name f))))) - ;; (string-match re name)) - (string-match re f))))) - (pred (cond - ((null predicate) reg-pred) - ((null reg-pred) predicate) - (t (lexical-let ((predicate predicate) - (reg-pred reg-pred)) - (lambda (f) - (and (funcall predicate f) - (funcall reg-pred f))))))) - (fun - (lexical-let ((pred pred) - (dir default-directory)) - (lambda (s p a) - ;; Remember the default-directory that was active when we built - ;; the completion table. - (let ((default-directory dir) - ;; The old code used only file-name-all-completions - ;; which ignores completion-ignored-extensions. - (completion-ignored-extensions nil)) - (completion-table-with-predicate - 'completion-file-name-table pred 'strict s p a))))) - ;; Indirect through a symbol rather than returning a lambda - ;; expression, so as to help catch bugs where the caller - ;; might treat the lambda expression as a list of completions. - (sym (make-symbol "pcomplete-read-file-name-internal"))) - (fset sym fun) - sym)) + (let* ((name (substitute-env-vars pcomplete-stub)) + (completion-ignore-case pcomplete-ignore-case) + (default-directory (expand-file-name + (or (file-name-directory name) + default-directory))) + above-cutoff) + (setq name (file-name-nondirectory name) + pcomplete-stub name) + (let ((completions + (file-name-all-completions name default-directory))) + (if regexp + (setq completions + (pcomplete-pare-list + completions nil + (function + (lambda (file) + (not (string-match regexp file))))))) + (if predicate + (setq completions + (pcomplete-pare-list + completions nil + (function + (lambda (file) + (not (funcall predicate file))))))) + (if (or pcomplete-file-ignore pcomplete-dir-ignore) + (setq completions + (pcomplete-pare-list + completions nil + (function + (lambda (file) + (if (eq (aref file (1- (length file))) + ?/) + (and pcomplete-dir-ignore + (string-match pcomplete-dir-ignore file)) + (and pcomplete-file-ignore + (string-match pcomplete-file-ignore file)))))))) + (setq above-cutoff (and pcomplete-cycle-cutoff-length + (> (length completions) + pcomplete-cycle-cutoff-length))) + (sort completions + (function + (lambda (l r) + ;; for the purposes of comparison, remove the + ;; trailing slash from directory names. + ;; Otherwise, "foo.old/" will come before "foo/", + ;; since . is earlier in the ASCII alphabet than + ;; / + (let ((left (if (eq (aref l (1- (length l))) + ?/) + (substring l 0 (1- (length l))) + l)) + (right (if (eq (aref r (1- (length r))) + ?/) + (substring r 0 (1- (length r))) + r))) + (if above-cutoff + (string-lessp left right) + (funcall pcomplete-compare-entry-function + left right))))))))) (defsubst pcomplete-all-entries (&optional regexp predicate) "Like `pcomplete-entries', but doesn't ignore any entries."