all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Portable dir-path separator?
@ 2013-06-26 18:01 Thorsten Jolitz
  2013-06-26 18:31 ` Michael Heerdegen
  0 siblings, 1 reply; 5+ messages in thread
From: Thorsten Jolitz @ 2013-06-26 18:01 UTC (permalink / raw)
  To: help-gnu-emacs


Hi List, 

is it portable to split absolute file names in Emacs Lisp with "/" as
separator? I searched for a related variable that abstracts away the
slash vs. backslash issue, but did not find one (`path-separator' is ':'
under GNU/Linux and probably not what I'm looking for).

-- 
cheers,
Thorsten





^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Portable dir-path separator?
       [not found] <mailman.2490.1372269697.22516.help-gnu-emacs@gnu.org>
@ 2013-06-26 18:08 ` Rustom Mody
  2013-06-26 18:31   ` Thorsten Jolitz
  0 siblings, 1 reply; 5+ messages in thread
From: Rustom Mody @ 2013-06-26 18:08 UTC (permalink / raw)
  To: help-gnu-emacs

On Wednesday, June 26, 2013 11:31:15 PM UTC+5:30, Thorsten Jolitz wrote:
> Hi List, 
> 
> is it portable to split absolute file names in Emacs Lisp with "/" as
> separator? I searched for a related variable that abstracts away the
> slash vs. backslash issue, but did not find one (`path-separator' is ':'
> under GNU/Linux and probably not what I'm looking for).
> 

Maybe you want things like file-name-directory from
(info "(elisp)File Name Components")

?


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Portable dir-path separator?
  2013-06-26 18:01 Portable dir-path separator? Thorsten Jolitz
@ 2013-06-26 18:31 ` Michael Heerdegen
  2013-06-26 18:56   ` Thorsten Jolitz
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Heerdegen @ 2013-06-26 18:31 UTC (permalink / raw)
  To: help-gnu-emacs

Hi Thorsten,

> is it portable to split absolute file names in Emacs Lisp with "/" as
> separator? I searched for a related variable that abstracts away the
> slash vs. backslash issue, but did not find one (`path-separator' is ':'
> under GNU/Linux and probably not what I'm looking for).

I think you want something like

(defun split-path (path)
  (split-path-1 path ()))

(defun split-path-1 (path accum)
  (let ((dir  (directory-file-name (file-name-directory path)))
	(name (file-name-nondirectory path)))
    (if (equal dir path)
	accum
      (split-path-1 dir (cons name accum)))))

I totally agree that something like that could be built in.


Regards,

Michael.




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Portable dir-path separator?
  2013-06-26 18:08 ` Rustom Mody
@ 2013-06-26 18:31   ` Thorsten Jolitz
  0 siblings, 0 replies; 5+ messages in thread
From: Thorsten Jolitz @ 2013-06-26 18:31 UTC (permalink / raw)
  To: help-gnu-emacs

Rustom Mody <rustompmody@gmail.com> writes:

> On Wednesday, June 26, 2013 11:31:15 PM UTC+5:30, Thorsten Jolitz wrote:
>> Hi List, 
>> 
>> is it portable to split absolute file names in Emacs Lisp with "/" as
>> separator? I searched for a related variable that abstracts away the
>> slash vs. backslash issue, but did not find one (`path-separator' is ':'
>> under GNU/Linux and probably not what I'm looking for).
>> 
>
> Maybe you want things like file-name-directory from
> (info "(elisp)File Name Components")
>
> ?

No, I rather want to do something like 

,------------------------------------------------------
| (split-string (expand-file-name file-name) separator)
`------------------------------------------------------

I'm on GNU/Linux and would use '/' as separator, but what if this code
is used on Windows or so? I thought there must be some OS independent
variable for this in Emacs - but did not find it yet. 

-- 
cheers,
Thorsten




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Portable dir-path separator?
  2013-06-26 18:31 ` Michael Heerdegen
@ 2013-06-26 18:56   ` Thorsten Jolitz
  0 siblings, 0 replies; 5+ messages in thread
From: Thorsten Jolitz @ 2013-06-26 18:56 UTC (permalink / raw)
  To: help-gnu-emacs

Michael Heerdegen <michael_heerdegen@web.de> writes:

Hi Michael,

>> is it portable to split absolute file names in Emacs Lisp with "/" as
>> separator? I searched for a related variable that abstracts away the
>> slash vs. backslash issue, but did not find one (`path-separator' is ':'
>> under GNU/Linux and probably not what I'm looking for).
>
> I think you want something like
>
> (defun split-path (path)
>   (split-path-1 path ()))
>
> (defun split-path-1 (path accum)
>   (let ((dir  (directory-file-name (file-name-directory path)))
> 	(name (file-name-nondirectory path)))
>     (if (equal dir path)
> 	accum
>       (split-path-1 dir (cons name accum)))))
>
> I totally agree that something like that could be built in.

Exactly what I wanted (and actually expected to be built in somehow).
Thanks! 

-- 
cheers,
Thorsten




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-06-26 18:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-26 18:01 Portable dir-path separator? Thorsten Jolitz
2013-06-26 18:31 ` Michael Heerdegen
2013-06-26 18:56   ` Thorsten Jolitz
     [not found] <mailman.2490.1372269697.22516.help-gnu-emacs@gnu.org>
2013-06-26 18:08 ` Rustom Mody
2013-06-26 18:31   ` Thorsten Jolitz

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.