Mercurial > emacs
comparison lisp/eshell/em-dirs.el @ 88155:d7ddb3e565de
sync with trunk
author | Henrik Enberg <henrik.enberg@telia.com> |
---|---|
date | Mon, 16 Jan 2006 00:03:54 +0000 |
parents | 6eb625bead4f |
children |
comparison
equal
deleted
inserted
replaced
88154:8ce476d3ba36 | 88155:d7ddb3e565de |
---|---|
1 ;;; em-dirs.el --- directory navigation commands | 1 ;;; em-dirs.el --- directory navigation commands |
2 | 2 |
3 ;; Copyright (C) 1999, 2000 Free Software Foundation | 3 ;; Copyright (C) 1999, 2000, 2002, 2003, 2004, |
4 ;; 2005 Free Software Foundation, Inc. | |
4 | 5 |
5 ;; Author: John Wiegley <johnw@gnu.org> | 6 ;; Author: John Wiegley <johnw@gnu.org> |
6 | 7 |
7 ;; This file is part of GNU Emacs. | 8 ;; This file is part of GNU Emacs. |
8 | 9 |
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 ;; GNU General Public License for more details. | 18 ;; GNU General Public License for more details. |
18 | 19 |
19 ;; You should have received a copy of the GNU General Public License | 20 ;; You should have received a copy of the GNU General Public License |
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the | 21 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
22 ;; Boston, MA 02111-1307, USA. | 23 ;; Boston, MA 02110-1301, USA. |
23 | 24 |
24 (provide 'em-dirs) | 25 (provide 'em-dirs) |
25 | 26 |
26 (eval-when-compile (require 'esh-maint)) | 27 (eval-when-compile (require 'esh-maint)) |
28 (require 'eshell) | |
27 | 29 |
28 (defgroup eshell-dirs nil | 30 (defgroup eshell-dirs nil |
29 "Directory navigation involves changing directories, examining the | 31 "Directory navigation involves changing directories, examining the |
30 current directory, maintaining a directory stack, and also keeping | 32 current directory, maintaining a directory stack, and also keeping |
31 track of a history of the last directory locations the user was in. | 33 track of a history of the last directory locations the user was in. |
273 (looking-at "\\([A-Za-z]:\\)\\([^/\\\\]\\|\\'\\)")) | 275 (looking-at "\\([A-Za-z]:\\)\\([^/\\\\]\\|\\'\\)")) |
274 (goto-char (match-end 1)) | 276 (goto-char (match-end 1)) |
275 (let* ((letter (match-string 1)) | 277 (let* ((letter (match-string 1)) |
276 (regexp (concat "\\`" letter)) | 278 (regexp (concat "\\`" letter)) |
277 (path (eshell-find-previous-directory regexp))) | 279 (path (eshell-find-previous-directory regexp))) |
278 (concat (or path letter) | 280 (concat (or path letter) "/")))) |
279 (char-to-string directory-sep-char))))) | |
280 | 281 |
281 (defun eshell-complete-user-reference () | 282 (defun eshell-complete-user-reference () |
282 "If there is a user reference, complete it." | 283 "If there is a user reference, complete it." |
283 (let ((arg (pcomplete-actual-arg))) | 284 (let ((arg (pcomplete-actual-arg))) |
284 (when (string-match "\\`~[a-z]*\\'" arg) | 285 (when (string-match "\\`~[a-z]*\\'" arg) |
297 (defun eshell/pwd (&rest args) | 298 (defun eshell/pwd (&rest args) |
298 "Change output from `pwd` to be cleaner." | 299 "Change output from `pwd` to be cleaner." |
299 (let* ((path default-directory) | 300 (let* ((path default-directory) |
300 (len (length path))) | 301 (len (length path))) |
301 (if (and (> len 1) | 302 (if (and (> len 1) |
302 (eq (aref path (1- len)) directory-sep-char) | 303 (eq (aref path (1- len)) ?/) |
303 (not (and (eshell-under-windows-p) | 304 (not (and (eshell-under-windows-p) |
304 (string-match "\\`[A-Za-z]:[\\\\/]\\'" path)))) | 305 (string-match "\\`[A-Za-z]:[\\\\/]\\'" path)))) |
305 (setq path (substring path 0 (1- (length path))))) | 306 (setq path (substring path 0 (1- (length path))))) |
306 (if eshell-pwd-convert-function | 307 (if eshell-pwd-convert-function |
307 (funcall eshell-pwd-convert-function path) | 308 (funcall eshell-pwd-convert-function path) |
321 (while (string-match "\\.\\.\\(\\.+\\)" path) | 322 (while (string-match "\\.\\.\\(\\.+\\)" path) |
322 (let* ((extra-dots (match-string 1 path)) | 323 (let* ((extra-dots (match-string 1 path)) |
323 (len (length extra-dots)) | 324 (len (length extra-dots)) |
324 replace-text) | 325 replace-text) |
325 (while (> len 0) | 326 (while (> len 0) |
326 (setq replace-text | 327 (setq replace-text (concat replace-text "/..") |
327 (concat replace-text | |
328 (char-to-string directory-sep-char) "..") | |
329 len (1- len))) | 328 len (1- len))) |
330 (setq path | 329 (setq path |
331 (replace-match replace-text t t path 1)))) | 330 (replace-match replace-text t t path 1)))) |
332 path) | 331 path) |
333 | 332 |
368 ((and path (string-match "^-\\([0-9]*\\)$" path)) | 367 ((and path (string-match "^-\\([0-9]*\\)$" path)) |
369 (let ((index (match-string 1 path))) | 368 (let ((index (match-string 1 path))) |
370 (setq path | 369 (setq path |
371 (ring-remove eshell-last-dir-ring | 370 (ring-remove eshell-last-dir-ring |
372 (if index | 371 (if index |
373 (string-to-int index) | 372 (string-to-number index) |
374 0))))) | 373 0))))) |
375 ((and path (string-match "^=\\(.*\\)$" path)) | 374 ((and path (string-match "^=\\(.*\\)$" path)) |
376 (let ((oldpath (eshell-find-previous-directory | 375 (let ((oldpath (eshell-find-previous-directory |
377 (match-string 1 path)))) | 376 (match-string 1 path)))) |
378 (if oldpath | 377 (if oldpath |
567 (write-region (point-min) (point-max) file nil | 566 (write-region (point-min) (point-max) file nil |
568 'no-message)))))))) | 567 'no-message)))))))) |
569 | 568 |
570 ;;; Code: | 569 ;;; Code: |
571 | 570 |
571 ;;; arch-tag: 1e9c5a95-f1bd-45f8-ad36-55aac706e787 | |
572 ;;; em-dirs.el ends here | 572 ;;; em-dirs.el ends here |