unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Re: Converting filenames
       [not found] <722c8495-60f9-4a06-9c36-2226dc942390@5g2000yqz.googlegroups.com>
@ 2010-07-01  0:42 ` Pascal J. Bourguignon
  2010-07-01  4:25 ` B. T. Raven
  2010-12-11  7:35 ` Drew Adams
  2 siblings, 0 replies; 5+ messages in thread
From: Pascal J. Bourguignon @ 2010-07-01  0:42 UTC (permalink / raw)
  To: help-gnu-emacs

Nordlöw <per.nordlow@gmail.com> writes:

> Is there an opposite function of expand-file-name() that converts "/
> home/per/" to "~/" if I am user per?

Yes.  All the functions already exist.  
You just have to discover their name.  

This function name discovering activity is called "programming".


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/


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

* Re: Converting filenames
       [not found] <722c8495-60f9-4a06-9c36-2226dc942390@5g2000yqz.googlegroups.com>
  2010-07-01  0:42 ` Converting filenames Pascal J. Bourguignon
@ 2010-07-01  4:25 ` B. T. Raven
  2010-07-01  4:31   ` B. T. Raven
  2010-12-11  7:35 ` Drew Adams
  2 siblings, 1 reply; 5+ messages in thread
From: B. T. Raven @ 2010-07-01  4:25 UTC (permalink / raw)
  To: help-gnu-emacs

Nordlöw wrote:
> Is there an opposite function of expand-file-name() that converts "/
> home/per/" to "~/" if I am user per?
> 
> Thanks in advance,
> Nordlöw

I don't think that a general inverse function would be useful since "~/"
is probably not a symlink or hard link but just string somehow hard
coded to expand to the fully qualified home path. What would the
putative abbrev-file-name do with dir/subdir/pic.jpg? The only sensible
thing is just to return its argument.

Something like this:

(if (equal (getenv "home") "/home/per")    (print "~/"))

illustrates what should happen if the Emacs process belongs to per.

Ed


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

* Re: Converting filenames
  2010-07-01  4:25 ` B. T. Raven
@ 2010-07-01  4:31   ` B. T. Raven
  2010-12-11  7:51     ` Kevin Rodgers
  0 siblings, 1 reply; 5+ messages in thread
From: B. T. Raven @ 2010-07-01  4:31 UTC (permalink / raw)
  To: help-gnu-emacs

B. T. Raven wrote:
> Nordlöw wrote:
>> Is there an opposite function of expand-file-name() that converts "/
>> home/per/" to "~/" if I am user per?
>>
>> Thanks in advance,
>> Nordlöw
> 
> I don't think that a general inverse function would be useful since "~/"
> is probably not a symlink or hard link but just string somehow hard
> coded to expand to the fully qualified home path. What would the
> putative abbrev-file-name do with dir/subdir/pic.jpg? The only sensible
> thing is just to return its argument.
> 
> Something like this:
> 
> (if (equal (getenv "home") "/home/per")    (print "~/"))
> 
> illustrates what should happen if the Emacs process belongs to per.
> 
> Ed

Oops, abbreviate-file-name actually exists but returns only "~". You
could wrap it in something that concats the "/"

Ed


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

* RE: Converting filenames
       [not found] <722c8495-60f9-4a06-9c36-2226dc942390@5g2000yqz.googlegroups.com>
  2010-07-01  0:42 ` Converting filenames Pascal J. Bourguignon
  2010-07-01  4:25 ` B. T. Raven
@ 2010-12-11  7:35 ` Drew Adams
  2 siblings, 0 replies; 5+ messages in thread
From: Drew Adams @ 2010-12-11  7:35 UTC (permalink / raw)
  To: 'Nordlöw', help-gnu-emacs

> Is there an opposite function of expand-file-name() that converts "/
> home/per/" to "~/" if I am user per?

`abbreviate-file-name'.
Except if your home dir is a root dir.




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

* Re: Converting filenames
  2010-07-01  4:31   ` B. T. Raven
@ 2010-12-11  7:51     ` Kevin Rodgers
  0 siblings, 0 replies; 5+ messages in thread
From: Kevin Rodgers @ 2010-12-11  7:51 UTC (permalink / raw)
  To: help-gnu-emacs

On 6/30/10 10:31 PM, B. T. Raven wrote:
> Oops, abbreviate-file-name actually exists but returns only "~". You
> could wrap it in something that concats the "/"

file-name-as-directory

-- 
Kevin Rodgers
Denver, Colorado, USA




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

end of thread, other threads:[~2010-12-11  7:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <722c8495-60f9-4a06-9c36-2226dc942390@5g2000yqz.googlegroups.com>
2010-07-01  0:42 ` Converting filenames Pascal J. Bourguignon
2010-07-01  4:25 ` B. T. Raven
2010-07-01  4:31   ` B. T. Raven
2010-12-11  7:51     ` Kevin Rodgers
2010-12-11  7:35 ` Drew Adams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).