Show
Ignore:
Timestamp:
05/18/06 16:19:18 (3 years ago)
Author:
miyoshi
Message:

Sync up with Emacs CVS HEAD.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lisp/shell.el

    r4058 r4085  
    151151 
    152152(defcustom shell-completion-fignore nil 
    153   "*List of suffixes to be disregarded during file/command completion. 
     153  "List of suffixes to be disregarded during file/command completion. 
    154154This variable is used to initialize `comint-completion-fignore' in the shell 
    155155buffer.  The default is nil, for compatibility with most shells. 
     
    200200 
    201201(defcustom shell-command-regexp "[^;&|\n]+" 
    202   "*Regexp to match a single command within a pipeline. 
     202  "Regexp to match a single command within a pipeline. 
    203203This is used for directory tracking and does not do a perfect job." 
    204204  :type 'regexp 
     
    206206 
    207207(defcustom shell-command-separator-regexp "[;&|\n \t]*" 
    208   "*Regexp to match a single command within a pipeline. 
     208  "Regexp to match a single command within a pipeline. 
    209209This is used for directory tracking and does not do a perfect job." 
    210210  :type 'regexp 
     
    212212 
    213213(defcustom shell-completion-execonly t 
    214   "*If non-nil, use executable files only for completion candidates. 
     214  "If non-nil, use executable files only for completion candidates. 
    215215This mirrors the optional behavior of tcsh. 
    216216 
     
    220220 
    221221(defcustom shell-popd-regexp "popd" 
    222   "*Regexp to match subshell commands equivalent to popd." 
     222  "Regexp to match subshell commands equivalent to popd." 
    223223  :type 'regexp 
    224224  :group 'shell-directories) 
    225225 
    226226(defcustom shell-pushd-regexp "pushd" 
    227   "*Regexp to match subshell commands equivalent to pushd." 
     227  "Regexp to match subshell commands equivalent to pushd." 
    228228  :type 'regexp 
    229229  :group 'shell-directories) 
    230230 
    231231(defcustom shell-pushd-tohome nil 
    232   "*If non-nil, make pushd with no arg behave as \"pushd ~\" (like cd). 
     232  "If non-nil, make pushd with no arg behave as \"pushd ~\" (like cd). 
    233233This mirrors the optional behavior of tcsh." 
    234234  :type 'boolean 
     
    236236 
    237237(defcustom shell-pushd-dextract nil 
    238   "*If non-nil, make \"pushd +n\" pop the nth dir to the stack top. 
     238  "If non-nil, make \"pushd +n\" pop the nth dir to the stack top. 
    239239This mirrors the optional behavior of tcsh." 
    240240  :type 'boolean 
     
    242242 
    243243(defcustom shell-pushd-dunique nil 
    244   "*If non-nil, make pushd only add unique directories to the stack. 
     244  "If non-nil, make pushd only add unique directories to the stack. 
    245245This mirrors the optional behavior of tcsh." 
    246246  :type 'boolean 
     
    248248 
    249249(defcustom shell-cd-regexp "cd" 
    250   "*Regexp to match subshell commands equivalent to cd." 
     250  "Regexp to match subshell commands equivalent to cd." 
    251251  :type 'regexp 
    252252  :group 'shell-directories) 
     
    257257      "[]a-zA-Z^_`\\[\\\\]:" 
    258258    nil) 
    259   "*If non-nil, is regexp used to track drive changes." 
     259  "If non-nil, is regexp used to track drive changes." 
    260260  :type '(choice regexp 
    261261                 (const nil)) 
     
    263263 
    264264(defcustom shell-dirtrack-verbose t 
    265   "*If non-nil, show the directory stack following directory change. 
     265  "If non-nil, show the directory stack following directory change. 
    266266This is effective only if directory tracking is enabled." 
    267267  :type 'boolean 
     
    269269 
    270270(defcustom explicit-shell-file-name nil 
    271   "*If non-nil, is file name to use for explicitly requested inferior shell." 
     271  "If non-nil, is file name to use for explicitly requested inferior shell." 
    272272  :type '(choice (const :tag "None" nil) file) 
    273273  :group 'shell) 
     
    279279      '("-i" "-T") 
    280280    '("-i")) 
    281   "*Args passed to inferior shell by M-x shell, if the shell is csh. 
     281  "Args passed to inferior shell by \\[shell], if the shell is csh. 
    282282Value is a list of strings, which may be nil." 
    283283  :type '(repeat (string :tag "Argument")) 
     
    297297        '("-i") 
    298298      '("--noediting" "-i"))) 
    299   "*Args passed to inferior shell by M-x shell, if the shell is bash. 
     299  "Args passed to inferior shell by \\[shell], if the shell is bash. 
    300300Value is a list of strings, which may be nil." 
    301301  :type '(repeat (string :tag "Argument")) 
     
    303303 
    304304(defcustom shell-input-autoexpand 'history 
    305   "*If non-nil, expand input command history references on completion. 
     305  "If non-nil, expand input command history references on completion. 
    306306This mirrors the optional behavior of tcsh (its autoexpand and histlit). 
    307307 
     
    434434  (make-local-variable 'shell-last-dir) 
    435435  (setq shell-last-dir nil) 
    436   (make-local-variable 'shell-dirtrackp) 
    437   (setq shell-dirtrackp t) 
    438   (add-hook 'comint-input-filter-functions 'shell-directory-tracker nil t) 
     436  (shell-dirtrack-mode 1) 
    439437  (setq comint-input-autoexpand shell-input-autoexpand) 
    440438  ;; This is not really correct, since the shell buffer does not really 
     
    559557  buffer) 
    560558 
    561 ;;; Don't do this when shell.el is loaded, only while dumping. 
     559;; Don't do this when shell.el is loaded, only while dumping. 
    562560;;;###autoload (add-hook 'same-window-buffer-names "*shell*") 
    563561 
    564562;;; Directory tracking 
    565 ;;; 
    566 ;;; This code provides the shell mode input sentinel 
    567 ;;;     SHELL-DIRECTORY-TRACKER 
    568 ;;; that tracks cd, pushd, and popd commands issued to the shell, and 
    569 ;;; changes the current directory of the shell buffer accordingly. 
    570 ;;; 
    571 ;;; This is basically a fragile hack, although it's more accurate than 
    572 ;;; the version in Emacs 18's shell.el. It has the following failings: 
    573 ;;; 1. It doesn't know about the cdpath shell variable. 
    574 ;;; 2. It cannot infallibly deal with command sequences, though it does well 
    575 ;;;    with these and with ignoring commands forked in another shell with ()s. 
    576 ;;; 3. More generally, any complex command is going to throw it. Otherwise, 
    577 ;;;    you'd have to build an entire shell interpreter in Emacs Lisp.  Failing 
    578 ;;;    that, there's no way to catch shell commands where cd's are buried 
    579 ;;;    inside conditional expressions, aliases, and so forth. 
    580 ;;; 
    581 ;;; The whole approach is a crock. Shell aliases mess it up. File sourcing 
    582 ;;; messes it up. You run other processes under the shell; these each have 
    583 ;;; separate working directories, and some have commands for manipulating 
    584 ;;; their w.d.'s (e.g., the lcd command in ftp). Some of these programs have 
    585 ;;; commands that do *not* affect the current w.d. at all, but look like they 
    586 ;;; do (e.g., the cd command in ftp).  In shells that allow you job 
    587 ;;; control, you can switch between jobs, all having different w.d.'s. So 
    588 ;;; simply saying %3 can shift your w.d.. 
    589 ;;; 
    590 ;;; The solution is to relax, not stress out about it, and settle for 
    591 ;;; a hack that works pretty well in typical circumstances. Remember 
    592 ;;; that a half-assed solution is more in keeping with the spirit of Unix, 
    593 ;;; anyway. Blech. 
    594 ;;; 
    595 ;;; One good hack not implemented here for users of programmable shells 
    596 ;;; is to program up the shell w.d. manipulation commands to output 
    597 ;;; a coded command sequence to the tty. Something like 
    598 ;;;     ESC | <cwd> | 
    599 ;;; where <cwd> is the new current working directory. Then trash the 
    600 ;;; directory tracking machinery currently used in this package, and 
    601 ;;; replace it with a process filter that watches for and strips out 
    602 ;;; these messages. 
     563;; 
     564;; This code provides the shell mode input sentinel 
     565;;     SHELL-DIRECTORY-TRACKER 
     566;; that tracks cd, pushd, and popd commands issued to the shell, and 
     567;; changes the current directory of the shell buffer accordingly. 
     568;; 
     569;; This is basically a fragile hack, although it's more accurate than 
     570;; the version in Emacs 18's shell.el. It has the following failings: 
     571;; 1. It doesn't know about the cdpath shell variable. 
     572;; 2. It cannot infallibly deal with command sequences, though it does well 
     573;;    with these and with ignoring commands forked in another shell with ()s. 
     574;; 3. More generally, any complex command is going to throw it. Otherwise, 
     575;;    you'd have to build an entire shell interpreter in Emacs Lisp.  Failing 
     576;;    that, there's no way to catch shell commands where cd's are buried 
     577;;    inside conditional expressions, aliases, and so forth. 
     578;; 
     579;; The whole approach is a crock. Shell aliases mess it up. File sourcing 
     580;; messes it up. You run other processes under the shell; these each have 
     581;; separate working directories, and some have commands for manipulating 
     582;; their w.d.'s (e.g., the lcd command in ftp). Some of these programs have 
     583;; commands that do *not* affect the current w.d. at all, but look like they 
     584;; do (e.g., the cd command in ftp).  In shells that allow you job 
     585;; control, you can switch between jobs, all having different w.d.'s. So 
     586;; simply saying %3 can shift your w.d.. 
     587;; 
     588;; The solution is to relax, not stress out about it, and settle for 
     589;; a hack that works pretty well in typical circumstances. Remember 
     590;; that a half-assed solution is more in keeping with the spirit of Unix, 
     591;; anyway. Blech. 
     592;; 
     593;; One good hack not implemented here for users of programmable shells 
     594;; is to program up the shell w.d. manipulation commands to output 
     595;; a coded command sequence to the tty. Something like 
     596;;     ESC | <cwd> | 
     597;; where <cwd> is the new current working directory. Then trash the 
     598;; directory tracking machinery currently used in this package, and 
     599;; replace it with a process filter that watches for and strips out 
     600;; these messages. 
    603601 
    604602(defun shell-directory-tracker (str) 
     
    608606default directory to track these commands. 
    609607 
    610 You may toggle this tracking on and off with M-x dirtrack-mode
    611 If Emacs gets confused, you can resync with the shell with M-x dirs
     608You may toggle this tracking on and off with \\[dirtrack-mode]
     609If Emacs gets confused, you can resync with the shell with \\[dirs]
    612610 
    613611See variables `shell-cd-regexp', `shell-chdrive-regexp', `shell-pushd-regexp', 
     
    678676      string))) 
    679677 
    680 ;;; popd [+n] 
     678;; popd [+n] 
    681679(defun shell-process-popd (arg) 
    682680  (let ((num (or (shell-extract-num arg) 0))) 
     
    704702      (expand-file-name dir)))) 
    705703 
    706 ;;; cd [dir] 
     704;; cd [dir] 
    707705(defun shell-process-cd (arg) 
    708706  (let ((new-dir (cond ((zerop (length arg)) (concat comint-file-name-prefix 
     
    714712    (shell-dirstack-message))) 
    715713 
    716 ;;; pushd [+n | dir] 
     714;; pushd [+n | dir] 
    717715(defun shell-process-pushd (arg) 
    718716  (let ((num (shell-extract-num arg))) 
     
    763761       (string-to-number str))) 
    764762 
    765  
    766 (defun shell-dirtrack-mode () 
     763(defvaralias 'shell-dirtrack-mode 'shell-dirtrackp) 
     764(define-minor-mode shell-dirtrack-mode 
    767765  "Turn directory tracking on and off in a shell buffer." 
    768   (interactive) 
    769   (if (setq shell-dirtrackp (not shell-dirtrackp)) 
    770       (setq list-buffers-directory default-directory) 
    771     (setq list-buffers-directory nil)
    772   (message "Directory tracking %s" (if shell-dirtrackp "ON" "OFF"))) 
    773  
    774 ;;; For your typing convenience: 
    775 (defalias 'shell-dirtrack-toggle 'shell-dirtrack-mode) 
     766  nil nil nil 
     767  (setq list-buffers-directory (if shell-dirtrack-mode default-directory)) 
     768  (if shell-dirtrack-mode 
     769      (add-hook 'comint-input-filter-functions 'shell-directory-tracker nil t
     770    (remove-hook 'comint-input-filter-functions 'shell-directory-tracker t))) 
     771 
     772;; For your typing convenience: 
     773(defalias 'shell-dirtrack-toggle 'shell-dirtrack-mode) ;??Convenience?? 
    776774(defalias 'dirtrack-toggle 'shell-dirtrack-mode) 
    777775(defalias 'dirtrack-mode 'shell-dirtrack-mode) 
     
    779777(defun shell-cd (dir) 
    780778  "Do normal `cd' to DIR, and set `list-buffers-directory'." 
     779  (cd dir) 
    781780  (if shell-dirtrackp 
    782       (setq list-buffers-directory (file-name-as-directory 
    783                                     (expand-file-name dir)))) 
    784   (cd dir)) 
     781      (setq list-buffers-directory default-directory))) 
    785782 
    786783(defun shell-resync-dirs () 
     
    842839          (error (message "Couldn't cd"))))))) 
    843840 
    844 ;;; For your typing convenience: 
     841;; For your typing convenience: 
    845842(defalias 'dirs 'shell-resync-dirs) 
    846843 
    847844 
    848 ;;; Show the current dirstack on the message line. 
    849 ;;; Pretty up dirs a bit by changing "/usr/jqr/foo" to "~/foo". 
    850 ;;; (This isn't necessary if the dirlisting is generated with a simple "dirs".) 
    851 ;;; All the commands that mung the buffer's dirstack finish by calling 
    852 ;;; this guy. 
     845;; Show the current dirstack on the message line. 
     846;; Pretty up dirs a bit by changing "/usr/jqr/foo" to "~/foo". 
     847;; (This isn't necessary if the dirlisting is generated with a simple "dirs".) 
     848;; All the commands that mung the buffer's dirstack finish by calling 
     849;; this guy. 
    853850(defun shell-dirstack-message () 
    854851  (when shell-dirtrack-verbose 
     
    10771074(provide 'shell) 
    10781075 
    1079 ;;; arch-tag: bcb5f12a-c1f4-4aea-a809-2504bd5bd797 
     1076;; arch-tag: bcb5f12a-c1f4-4aea-a809-2504bd5bd797 
    10801077;;; shell.el ends here