all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Directory name to variable (dired?)
@ 2018-10-07 21:49 Tim Johnson
  2018-10-07 23:02 ` Drew Adams
  2018-10-07 23:18 ` Noam Postavsky
  0 siblings, 2 replies; 16+ messages in thread
From: Tim Johnson @ 2018-10-07 21:49 UTC (permalink / raw
  To: Emacs

My Emacs is :
GNU Emacs 26.1

Is there a function that returns a directory and full path
so that it could be assigned to a variable?

Ideally, dired would be a great place to start, as the directory
path is at the top of the screen.

thanks

-- 
Tim Johnson
http://www.tj49.com



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

* RE: Directory name to variable (dired?)
  2018-10-07 21:49 Directory name to variable (dired?) Tim Johnson
@ 2018-10-07 23:02 ` Drew Adams
  2018-10-07 23:14   ` Tim Johnson
  2018-10-07 23:18 ` Noam Postavsky
  1 sibling, 1 reply; 16+ messages in thread
From: Drew Adams @ 2018-10-07 23:02 UTC (permalink / raw
  To: Tim Johnson, Emacs

> Is there a function that returns a directory and full path
> so that it could be assigned to a variable?
> 
> Ideally, dired would be a great place to start, as the directory
> path is at the top of the screen.

In Dired, `M-0 w' invokes command `dired-copy-filename-as-kill'
with prefix arg 0, which copies the absolute name of the file
named on the current line.

Non-interactively, (dired-copy-filename-as-kill 0) does the
same thing.

Then (setq foo (current-kill 0)) sets variable `foo' to a string
with that absolute file name.




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

* Re: Directory name to variable (dired?)
  2018-10-07 23:02 ` Drew Adams
@ 2018-10-07 23:14   ` Tim Johnson
  2018-10-08  0:02     ` Drew Adams
  0 siblings, 1 reply; 16+ messages in thread
From: Tim Johnson @ 2018-10-07 23:14 UTC (permalink / raw
  To: Emacs

* Drew Adams <drew.adams@oracle.com> [181007 15:07]:
> > Is there a function that returns a directory and full path
> > so that it could be assigned to a variable?
> > 
> > Ideally, dired would be a great place to start, as the directory
> > path is at the top of the screen.
> 
> In Dired, `M-0 w' invokes command `dired-copy-filename-as-kill'
> with prefix arg 0, which copies the absolute name of the file
> named on the current line.
> 
> Non-interactively, (dired-copy-filename-as-kill 0) does the
> same thing.
> 
> Then (setq foo (current-kill 0)) sets variable `foo' to a string
> with that absolute file name.
  Thanks Drew. I can use that, and without adding another package.
  Cheers

-- 
Tim Johnson
http://www.tj49.com



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

* Re: Directory name to variable (dired?)
  2018-10-07 21:49 Directory name to variable (dired?) Tim Johnson
  2018-10-07 23:02 ` Drew Adams
@ 2018-10-07 23:18 ` Noam Postavsky
  2018-10-08  0:05   ` Tim Johnson
  1 sibling, 1 reply; 16+ messages in thread
From: Noam Postavsky @ 2018-10-07 23:18 UTC (permalink / raw
  To: Help Gnu Emacs mailing list

On Sun, 7 Oct 2018 at 17:55, Tim Johnson <tim@akwebsoft.com> wrote:

> Is there a function that returns a directory and full path
> so that it could be assigned to a variable?

Which directory?

> Ideally, dired would be a great place to start, as the directory
> path is at the top of the screen.

The one at the top of the screen is already in variable `default-directory'.



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

* RE: Directory name to variable (dired?)
  2018-10-07 23:14   ` Tim Johnson
@ 2018-10-08  0:02     ` Drew Adams
  2018-10-08  0:20       ` Tim Johnson
  0 siblings, 1 reply; 16+ messages in thread
From: Drew Adams @ 2018-10-08  0:02 UTC (permalink / raw
  To: Tim Johnson, Emacs

> > > Is there a function that returns a directory and full path
> > > so that it could be assigned to a variable?
> > >
> > > Ideally, dired would be a great place to start, as the directory
> > > path is at the top of the screen.
> >
> > In Dired, `M-0 w' invokes command `dired-copy-filename-as-kill'
> > with prefix arg 0, which copies the absolute name of the file
> > named on the current line.
> >
> > Non-interactively, (dired-copy-filename-as-kill 0) does the
> > same thing.
> >
> > Then (setq foo (current-kill 0)) sets variable `foo' to a string
> > with that absolute file name.

>   Thanks Drew. I can use that, and without adding another package.

This works on any subdir line, to get the absolute name of
that subdir. And it works on any file name. And as Noam
said, you can use variable `default-directory' for the name
of the main directory.



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

* Re: Directory name to variable (dired?)
  2018-10-07 23:18 ` Noam Postavsky
@ 2018-10-08  0:05   ` Tim Johnson
  2018-10-08 10:56     ` Noam Postavsky
  0 siblings, 1 reply; 16+ messages in thread
From: Tim Johnson @ 2018-10-08  0:05 UTC (permalink / raw
  To: help-gnu-emacs

* Noam Postavsky <npostavs@gmail.com> [181007 15:32]:
> On Sun, 7 Oct 2018 at 17:55, Tim Johnson <tim@akwebsoft.com> wrote:
> 
> > Is there a function that returns a directory and full path
> > so that it could be assigned to a variable?
> 
> Which directory?
  Any

> > Ideally, dired would be a great place to start, as the directory
> > path is at the top of the screen.
> 
> The one at the top of the screen is already in variable `default-directory'.
  Understood. 

  It looks like `default-directory changes to whichever directory is
  logged. If that's the case, then that is what I'm looking for. :)

  thanks. 

-- 
Tim Johnson
http://www.tj49.com



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

* Re: Directory name to variable (dired?)
  2018-10-08  0:02     ` Drew Adams
@ 2018-10-08  0:20       ` Tim Johnson
  2018-10-08  1:55         ` Drew Adams
  0 siblings, 1 reply; 16+ messages in thread
From: Tim Johnson @ 2018-10-08  0:20 UTC (permalink / raw
  To: help-gnu-emacs

* Drew Adams <drew.adams@oracle.com> [181007 16:08]:
> > > > Is there a function that returns a directory and full path
> > > > so that it could be assigned to a variable?
> > > >
> > > > Ideally, dired would be a great place to start, as the directory
> > > > path is at the top of the screen.
> > >
> > > In Dired, `M-0 w' invokes command `dired-copy-filename-as-kill'
> > > with prefix arg 0, which copies the absolute name of the file
> > > named on the current line.
> > >
> > > Non-interactively, (dired-copy-filename-as-kill 0) does the
> > > same thing.
> > >
> > > Then (setq foo (current-kill 0)) sets variable `foo' to a string
> > > with that absolute file name.
> 
> >   Thanks Drew. I can use that, and without adding another package.
> 
> This works on any subdir line, to get the absolute name of
> that subdir. And it works on any file name. And as Noam
> said, you can use variable `default-directory' for the name
> of the main directory.
  And I note that `default-directory is buffer local, so my variable
  assignment must be made while I am still in dired.

  thnx

-- 
Tim Johnson
http://www.tj49.com



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

* RE: Directory name to variable (dired?)
  2018-10-08  0:20       ` Tim Johnson
@ 2018-10-08  1:55         ` Drew Adams
  2018-10-08 15:08           ` Tim Johnson
  0 siblings, 1 reply; 16+ messages in thread
From: Drew Adams @ 2018-10-08  1:55 UTC (permalink / raw
  To: Tim Johnson, help-gnu-emacs

>   And I note that `default-directory is buffer local, so my variable
>   assignment must be made while I am still in dired.

It is buffer-local, but it is available in any buffer.



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

* Re: Directory name to variable (dired?)
  2018-10-08  0:05   ` Tim Johnson
@ 2018-10-08 10:56     ` Noam Postavsky
  2018-10-08 15:42       ` Tim Johnson
  0 siblings, 1 reply; 16+ messages in thread
From: Noam Postavsky @ 2018-10-08 10:56 UTC (permalink / raw
  To: Help Gnu Emacs mailing list

On Sun, 7 Oct 2018 at 20:05, Tim Johnson <tim@akwebsoft.com> wrote:
>
> * Noam Postavsky <npostavs@gmail.com> [181007 15:32]:
> > On Sun, 7 Oct 2018 at 17:55, Tim Johnson <tim@akwebsoft.com> wrote:
> >
> > > Is there a function that returns a directory and full path
> > > so that it could be assigned to a variable?
> >
> > Which directory?
>   Any

"/" is a directory, so you don't need a function or a variable, but I
don't quite understand how you could be looking for "any" directory...



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

* Re: Directory name to variable (dired?)
  2018-10-08  1:55         ` Drew Adams
@ 2018-10-08 15:08           ` Tim Johnson
  2018-10-08 15:18             ` Tim Johnson
  2018-10-08 20:12             ` Stefan Monnier
  0 siblings, 2 replies; 16+ messages in thread
From: Tim Johnson @ 2018-10-08 15:08 UTC (permalink / raw
  To: help-gnu-emacs

* Drew Adams <drew.adams@oracle.com> [181007 17:59]:
> >   And I note that `default-directory is buffer local, so my variable
> >   assignment must be made while I am still in dired.
> 
> It is buffer-local, but it is available in any buffer.
  To determine if a buffer is a dired buffer, it seems that I can
  verify that by evaluating `dired-omit-mode 

  Is there a more idiomatic way to do so?

  thanks again

-- 
Tim Johnson
http://www.tj49.com



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

* Re: Directory name to variable (dired?)
  2018-10-08 15:08           ` Tim Johnson
@ 2018-10-08 15:18             ` Tim Johnson
  2018-10-08 15:27               ` Noam Postavsky
  2018-10-08 15:56               ` Drew Adams
  2018-10-08 20:12             ` Stefan Monnier
  1 sibling, 2 replies; 16+ messages in thread
From: Tim Johnson @ 2018-10-08 15:18 UTC (permalink / raw
  To: help-gnu-emacs

* Tim Johnson <tim@akwebsoft.com> [181008 07:15]:
> * Drew Adams <drew.adams@oracle.com> [181007 17:59]:
> > >   And I note that `default-directory is buffer local, so my variable
> > >   assignment must be made while I am still in dired.
> > 
> > It is buffer-local, but it is available in any buffer.
>   To determine if a buffer is a dired buffer, it seems that I can
>   verify that by evaluating `dired-omit-mode 
> 
>   Is there a more idiomatic way to do so?
  Duh! Asked and answered: Probably 
  something like (eq (major-mode) "dired-mode") ;; untested
  thanks to everyone, good thread
-- 
Tim Johnson
http://www.tj49.com



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

* Re: Directory name to variable (dired?)
  2018-10-08 15:18             ` Tim Johnson
@ 2018-10-08 15:27               ` Noam Postavsky
  2018-10-08 15:56               ` Drew Adams
  1 sibling, 0 replies; 16+ messages in thread
From: Noam Postavsky @ 2018-10-08 15:27 UTC (permalink / raw
  To: Help Gnu Emacs mailing list

On Mon, 8 Oct 2018 at 11:18, Tim Johnson <tim@akwebsoft.com> wrote:

> >   To determine if a buffer is a dired buffer, it seems that I can
> >   verify that by evaluating `dired-omit-mode
> >
> >   Is there a more idiomatic way to do so?
>   Duh! Asked and answered: Probably
>   something like (eq (major-mode) "dired-mode") ;; untested

You'll want to single quote 'dired-mode the symbol for `eq'
comparisons. Possibly use the `derived-mode-p' function instead.



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

* Re: Directory name to variable (dired?)
  2018-10-08 10:56     ` Noam Postavsky
@ 2018-10-08 15:42       ` Tim Johnson
  0 siblings, 0 replies; 16+ messages in thread
From: Tim Johnson @ 2018-10-08 15:42 UTC (permalink / raw
  To: help-gnu-emacs

* Noam Postavsky <npostavs@gmail.com> [181008 02:57]:
> On Sun, 7 Oct 2018 at 20:05, Tim Johnson <tim@akwebsoft.com> wrote:
> >
> > * Noam Postavsky <npostavs@gmail.com> [181007 15:32]:
> > > On Sun, 7 Oct 2018 at 17:55, Tim Johnson <tim@akwebsoft.com> wrote:
> > >
> > > > Is there a function that returns a directory and full path
> > > > so that it could be assigned to a variable?
> > >
> > > Which directory?
> >   Any
> 
> "/" is a directory, so you don't need a function or a variable, but I
> don't quite understand how you could be looking for "any" directory...
  I don't wish to restrict where I might navigate to and
  subsequently grab a directory path. 
  
  I would not likely use ~/ or anything above...

  currently the specific application would be to change or
  add paths under something like ~/prj/emacs-desktops where
  project-specific desktop files are located.

  Although the application is currently of limited scope, it could
  expand, but not by much. I'm a retired programmer and just trying
  to keep my brain from atropyhing ...

  cheers
-- 
Tim Johnson
http://www.tj49.com



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

* RE: Directory name to variable (dired?)
  2018-10-08 15:18             ` Tim Johnson
  2018-10-08 15:27               ` Noam Postavsky
@ 2018-10-08 15:56               ` Drew Adams
  1 sibling, 0 replies; 16+ messages in thread
From: Drew Adams @ 2018-10-08 15:56 UTC (permalink / raw
  To: Tim Johnson, help-gnu-emacs

> >   To determine if a buffer is a dired buffer, it seems that I can
> >   verify that by evaluating `dired-omit-mode
> >
> >   Is there a more idiomatic way to do so?
>   Duh! Asked and answered: Probably
>   something like (eq (major-mode) "dired-mode") ;; untested
>   thanks to everyone, good thread

Use `derived-mode-p', rather than test for equality.



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

* Re: Directory name to variable (dired?)
  2018-10-08 15:08           ` Tim Johnson
  2018-10-08 15:18             ` Tim Johnson
@ 2018-10-08 20:12             ` Stefan Monnier
  2018-10-08 20:50               ` Tim Johnson
  1 sibling, 1 reply; 16+ messages in thread
From: Stefan Monnier @ 2018-10-08 20:12 UTC (permalink / raw
  To: help-gnu-emacs

>   Is there a more idiomatic way to do so?

(derived-mode-p 'dired-mode) is the official way to do that.


        Stefan




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

* Re: Directory name to variable (dired?)
  2018-10-08 20:12             ` Stefan Monnier
@ 2018-10-08 20:50               ` Tim Johnson
  0 siblings, 0 replies; 16+ messages in thread
From: Tim Johnson @ 2018-10-08 20:50 UTC (permalink / raw
  To: help-gnu-emacs

* Stefan Monnier <monnier@iro.umontreal.ca> [181008 12:46]:
> >   Is there a more idiomatic way to do so?
> 
> (derived-mode-p 'dired-mode) is the official way to do that.
  Understood ... and implemented.
  thank you
-- 
Tim Johnson
http://www.tj49.com



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

end of thread, other threads:[~2018-10-08 20:50 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-07 21:49 Directory name to variable (dired?) Tim Johnson
2018-10-07 23:02 ` Drew Adams
2018-10-07 23:14   ` Tim Johnson
2018-10-08  0:02     ` Drew Adams
2018-10-08  0:20       ` Tim Johnson
2018-10-08  1:55         ` Drew Adams
2018-10-08 15:08           ` Tim Johnson
2018-10-08 15:18             ` Tim Johnson
2018-10-08 15:27               ` Noam Postavsky
2018-10-08 15:56               ` Drew Adams
2018-10-08 20:12             ` Stefan Monnier
2018-10-08 20:50               ` Tim Johnson
2018-10-07 23:18 ` Noam Postavsky
2018-10-08  0:05   ` Tim Johnson
2018-10-08 10:56     ` Noam Postavsky
2018-10-08 15:42       ` Tim Johnson

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.