home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / gnu / emacs / help / 5527 < prev    next >
Encoding:
Text File  |  1993-01-27  |  3.6 KB  |  98 lines

  1. Newsgroups: gnu.emacs.help
  2. Path: sparky!uunet!uunet.ca!canrem!telly!utzoo!torn!spool.mu.edu!yale.edu!cs.yale.edu!cs.yale.edu!choo
  3. From: choo@cs.yale.edu (Young-il Choo)
  4. Subject: Re: Allowing SPACE in filename (find-file, dired, etc)
  5. In-Reply-To: shenton@troll.gsfc.nasa.gov's message of Tue, 26 Jan 1993 18: 47:27 GMT
  6. Message-ID: <1993Jan27.222737.25636@cs.yale.edu>
  7. Sender: news@cs.yale.edu (Usenet News)
  8. Nntp-Posting-Host: systemsz-gw.cs.yale.edu
  9. Organization: Yale Univ Computics
  10. References: <SHENTON.93Jan26134727@troll.gsfc.nasa.gov>
  11. Date: Wed, 27 Jan 1993 22:27:37 GMT
  12. Lines: 84
  13.  
  14. In article <SHENTON.93Jan26134727@troll.gsfc.nasa.gov> shenton@troll.gsfc.nasa.gov (Chris Shenton) writes:
  15.  
  16. > I'm editing files which frequently have space in their filename, and
  17. > would like the find-file functions in -- for example -- dired to
  18. > recognize the fullname, not just up to the first space.
  19.  
  20. > Anyone have ideas on how to do this?
  21.  
  22. Here are some functions in "dired-plus.el", which are automatically loaded
  23. by having the following in my .emacs
  24.  
  25. (setq dired-mode-hook
  26.       (function
  27.        (lambda ()
  28.      (require 'dired-plus))))
  29.  
  30.  
  31. ;;; dired-plus.el  -- modifications to handle file names containing spaces
  32. ;;; Dec 1992          Young-il Choo  <choo-young-il@cs.yale.edu>
  33.  
  34. ;;The way I get the whole file name is by searching for eol.  This can cause
  35. ;;trouble since I like to have the symbolic links visible in dired-mode.  So,
  36. ;;I have a function that removes the stuff after " -> ".
  37.  
  38. (provide 'dired-plus)
  39.  
  40. (defun dired-get-long-filename (&optional localp no-error-if-not-filep)
  41.   "In dired, return name of file, which may contain spaces,
  42. mentioned on this line.
  43. Value returned normally includes the directory name.
  44. A non-nil 1st argument means do not include it.  A non-nil 2nd argument
  45. says return nil if no filename on this line, otherwise an error occurs."
  46.   (let (eol)
  47.     (save-excursion
  48.       (end-of-line)
  49.       (setq eol (point))
  50.       (beginning-of-line)
  51.       (if (re-search-forward
  52.        "\\(Jan\\|Feb\\|Mar\\|Apr\\|May\\|Jun\\|Jul\\|Aug\\|Sep\\|Oct\\|Nov\\|Dec\\)[ ]+[0-9]+"
  53.        eol t)
  54.       (progn (skip-chars-forward " ")
  55.          (skip-chars-forward "^ " eol)
  56.          (skip-chars-forward " " eol)
  57.          (let ((beg (point)))
  58.            (skip-chars-forward "^\n") ;; first eol [YIC]
  59.            (dired-remove-symbolic-link ;; [YIC]
  60.             (if localp
  61.             (buffer-substring beg (point))
  62.               ;; >> uses default-directory, could lose on cd, multiple.
  63.               (concat default-directory (buffer-substring beg (point))))
  64.             )
  65.            ))
  66.     (if no-error-if-not-filep nil
  67.       (error "No file on this line"))))))
  68.  
  69. (defun dired-remove-symbolic-link (string)
  70.   "Gets rid of the -> symbol in the string for dired."
  71.   (substring string 0 
  72.          (if (string-match " -> " string) (match-beginning 0) nil)))
  73.  
  74. ;;;(fset 'dired-simple-get-filename (symbol-function 'dired-get-filename))
  75.  
  76. (defun dired-get-filename (&optional localp no-error-if-not-filep)
  77.   "Call \\[dired-get-long-filename].
  78. Then, if dired-listing-switches contains the F flag,
  79. fix up the filename by getting rid of the extra character."
  80.   (let ((filename (dired-get-long-filename localp no-error-if-not-filep))
  81.     eol)
  82.     (if (and (string-match "F" dired-listing-switches)
  83.          (save-excursion
  84.            (end-of-line)
  85.            (setq eol (point))
  86.            (beginning-of-line)
  87.            (re-search-forward
  88.         (concat "^."
  89.             (if (string-match "i" dired-listing-switches)
  90.                 "\\s-+[0-9]+" "")
  91.             (if (string-match "s" dired-listing-switches)
  92.                 "\\s-+[0-9]+" "")
  93.             "\\s-+\\([ds]\\|\\-..x\\|\\-.....x\\|\\-........x\\)")
  94.         eol t)))
  95.     (substring filename 0 (1- (length filename)))
  96.       filename)))
  97. ;;; end of dired-plus.el
  98.