🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

5 total messages Started by Chris Shenton Tue, 26 Jan 1993 18:47
Allowing SPACE in filename (find-file, dired, etc)
#2229
Author: Chris Shenton
Date: Tue, 26 Jan 1993 18:47
9 lines
835 bytes
I'm editing files which frequently have space in their filename, and
would like the find-file functions in -- for example -- dired to
recognize the fullname, not just up to the first space.

Anyone have ideas on how to do this?

Thanks.
--
-- Chris Shenton    shenton@nsisrv.gsfc.nasa.gov    NASA/GSFC/HSTX 301-286-7905
Re: Allowing SPACE in filename (find-file, dired, etc)
#2221
Author: Scott D Kalter
Date: Wed, 27 Jan 1993 20:53
20 lines
1278 bytes
In article <SHENTON.93Jan26134727@troll.gsfc.nasa.gov> shenton@troll.gsfc.nasa.gov (Chris Shenton) writes:

-> Date: Tue, 26 Jan 1993 18:47:27 GMT
-> 
-> I'm editing files which frequently have space in their filename, and
-> would like the find-file functions in -- for example -- dired to
-> recognize the fullname, not just up to the first space.
-> 
-> Anyone have ideas on how to do this?

Try using C-q space when you need to use a space in a filename (a
questionable practice in itself).  So, for instance, to find the file:

	foo bar

You would type C-x C-f f o o C-q   b a r

Completion does work once you get past the space.

-sdk
Re: Allowing SPACE in filename (find-file, dired, etc)
#2219
Author: Young-il Choo
Date: Wed, 27 Jan 1993 22:27
84 lines
3745 bytes
In article <SHENTON.93Jan26134727@troll.gsfc.nasa.gov> shenton@troll.gsfc.nasa.gov (Chris Shenton) writes:

> I'm editing files which frequently have space in their filename, and
> would like the find-file functions in -- for example -- dired to
> recognize the fullname, not just up to the first space.

> Anyone have ideas on how to do this?

Here are some functions in "dired-plus.el", which are automatically loaded
by having the following in my .emacs

(setq dired-mode-hook
      (function
       (lambda ()
	 (require 'dired-plus))))


;;; dired-plus.el  -- modifications to handle file names containing spaces
;;; Dec 1992          Young-il Choo  <choo-young-il@cs.yale.edu>

;;The way I get the whole file name is by searching for eol.  This can cause
;;trouble since I like to have the symbolic links visible in dired-mode.  So,
;;I have a function that removes the stuff after " -> ".

(provide 'dired-plus)

(defun dired-get-long-filename (&optional localp no-error-if-not-filep)
  "In dired, return name of file, which may contain spaces,
mentioned on this line.
Value returned normally includes the directory name.
A non-nil 1st argument means do not include it.  A non-nil 2nd argument
says return nil if no filename on this line, otherwise an error occurs."
  (let (eol)
    (save-excursion
      (end-of-line)
      (setq eol (point))
      (beginning-of-line)
      (if (re-search-forward
	   "\\(Jan\\|Feb\\|Mar\\|Apr\\|May\\|Jun\\|Jul\\|Aug\\|Sep\\|Oct\\|Nov\\|Dec\\)[ ]+[0-9]+"
	   eol t)
	  (progn (skip-chars-forward " ")
		 (skip-chars-forward "^ " eol)
		 (skip-chars-forward " " eol)
		 (let ((beg (point)))
		   (skip-chars-forward "^\n") ;; first eol [YIC]
		   (dired-remove-symbolic-link ;; [YIC]
		    (if localp
			(buffer-substring beg (point))
		      ;; >> uses default-directory, could lose on cd, multiple.
		      (concat default-directory (buffer-substring beg (point))))
		    )
		   ))
	(if no-error-if-not-filep nil
	  (error "No file on this line"))))))

(defun dired-remove-symbolic-link (string)
  "Gets rid of the -> symbol in the string for dired."
  (substring string 0 
	     (if (string-match " -> " string) (match-beginning 0) nil)))

;;;(fset 'dired-simple-get-filename (symbol-function 'dired-get-filename))

(defun dired-get-filename (&optional localp no-error-if-not-filep)
  "Call \\[dired-get-long-filename].
Then, if dired-listing-switches contains the F flag,
fix up the filename by getting rid of the extra character."
  (let ((filename (dired-get-long-filename localp no-error-if-not-filep))
	eol)
    (if (and (string-match "F" dired-listing-switches)
	     (save-excursion
	       (end-of-line)
	       (setq eol (point))
	       (beginning-of-line)
	       (re-search-forward
		(concat "^."
			(if (string-match "i" dired-listing-switches)
			    "\\s-+[0-9]+" "")
			(if (string-match "s" dired-listing-switches)
			    "\\s-+[0-9]+" "")
			"\\s-+\\([ds]\\|\\-..x\\|\\-.....x\\|\\-........x\\)")
		eol t)))
	(substring filename 0 (1- (length filename)))
      filename)))
;;; end of dired-plus.el
Re: Allowing SPACE in filename (find-file, dired, etc)
#2237
Author: Frank Munkert
Date: Thu, 28 Jan 1993 06:20
15 lines
1011 bytes
shenton@troll.gsfc.nasa.gov (Chris Shenton) writes:
>I'm editing files which frequently have space in their filename, and
>would like the find-file functions in -- for example -- dired to
>recognize the fullname, not just up to the first space.

>Anyone have ideas on how to do this?

Just type <TAB> to complete the filename (instead of <SPACE>).

- Frank

--
--------------------------------------------------------------------
Frank Munkert * Abt. LN * Geb. 903 * Raum 027 * Tel. (0911) 526-6304
--------------------------------------------------------------------
Re: Allowing SPACE in filename (find-file, dired, etc)
#2246
Author: Viktor Haag
Date: Thu, 28 Jan 1993 16:44
48 lines
2394 bytes
In article <SHENTON.93Jan26134727@troll.gsfc.nasa.gov> shenton@troll.gsfc.nasa.gov (Chris Shenton) writes:
>I'm editing files which frequently have space in their filename, and
>would like the find-file functions in -- for example -- dired to
>recognize the fullname, not just up to the first space.
>
>Anyone have ideas on how to do this?
>
>Thanks.
>--
>-- Chris Shenton    shenton@nsisrv.gsfc.nasa.gov    NASA/GSFC/HSTX 301-286-7905


Well, I'm not saying it can't be done, but as far as I can see

        dired-find-file (dired.el) uses find-file (files.el)

find-file takes a filename as an arg and calls find-file-noselect,
which finds the file, reads it into a buffer and returns the buffer.

find-file-noselect sets the filename to (expand-file-name filename),
and I can't find any source for expand-file-name.  Describe-function
gives the following info on expand-file-name:

expand-file-name:
Convert FILENAME to absolute, and canonicalize it.
Second arg DEFAULT is directory to start with if FILENAME is relative
 (does not start with slash); if DEFAULT is nil or missing,
the current buffer's value of default-directory is used.
Filenames containing . or .. as components are simplified;
initial ~ is expanded.  See also the function
substitute-in-file-name.

From this explanation, it seems that expand-file-name takes the
filename which might include relative references and expands it to a
full path name.  This may involve disregarding spaces internal to the
filename arg passed to expand-file-name.  Of course, I'm no expert --
anyone out there with an expert's explanation of this problem?






-- 
Viktor Haag                                     viktor@mks.com
Mortice Kern Systems                            (519) 884-8469
35 King North, Waterloo, Ontario                ext. 241
"we are not thugs. we are vitamin supplements to justice ..." | a selector
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads