all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to setup default program to launch directory?
@ 2021-10-13 21:10 Jean Louis
  2021-10-13 22:02 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-10-14  0:18 ` Michael Heerdegen
  0 siblings, 2 replies; 15+ messages in thread
From: Jean Louis @ 2021-10-13 21:10 UTC (permalink / raw)
  To: Help GNU Emacs


I am using `dired-guess-shell-alist-user' to launch various programs
on files. For example on *.mp4 files I will launch `mpv' program.

I would like to launch programs on directories, is there any way to
set it up by default? This is also useful to launch videos on
directory. 



Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



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

* Re: How to setup default program to launch directory?
  2021-10-13 21:10 How to setup default program to launch directory? Jean Louis
@ 2021-10-13 22:02 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-10-14  0:18 ` Michael Heerdegen
  1 sibling, 0 replies; 15+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-10-13 22:02 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

> I am using `dired-guess-shell-alist-user' ...

I don't have that?

> For example on *.mp4 files I will launch `mpv' program.

Wisely ...

> I would like to launch programs on directories, is there any
> way to set it up by default? This is also useful to launch
> videos on directory.

What do you mean, launch programs/videos on directories?

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: How to setup default program to launch directory?
  2021-10-13 21:10 How to setup default program to launch directory? Jean Louis
  2021-10-13 22:02 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-10-14  0:18 ` Michael Heerdegen
  2021-10-14  0:30   ` Michael Heerdegen
  2021-10-17  5:32   ` Jean Louis
  1 sibling, 2 replies; 15+ messages in thread
From: Michael Heerdegen @ 2021-10-14  0:18 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis <bugs@gnu.support> writes:

> I would like to launch programs on directories, is there any way to
> set it up by default? This is also useful to launch videos on
> directory. 

In each entry (REGEXP COMMAND...) in `dired-guess-shell-alist-user',
COMMAND

| can either be a string or a Lisp expression that evaluates to a
| string.  If this expression needs to consult the name of the file for
| which the shell commands are being requested, it can access that file
| name as the variable `file'.

(quoting from the docstring).  This is what you want to use.  Use a
catchall REGEXP and make COMMAND an expression that returns something
for directories, and nil else.  AFAICT COMMAND is also allowed to return
a list of strings.

I made it so that the expression also looks inside the directory, and
when it's full of images or media files, I return appropriate viewers.

Michael.




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

* Re: How to setup default program to launch directory?
  2021-10-14  0:18 ` Michael Heerdegen
@ 2021-10-14  0:30   ` Michael Heerdegen
  2021-10-17  5:21     ` Jean Louis
  2021-10-17  5:32   ` Jean Louis
  1 sibling, 1 reply; 15+ messages in thread
From: Michael Heerdegen @ 2021-10-14  0:30 UTC (permalink / raw)
  To: help-gnu-emacs

I wrote:

> AFAICT COMMAND is also allowed to return a list of strings.

Apparently only my personal modified version supports that.  Do you
think that would be a useful feature in general?

Michael.




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

* Re: How to setup default program to launch directory?
  2021-10-14  0:30   ` Michael Heerdegen
@ 2021-10-17  5:21     ` Jean Louis
  0 siblings, 0 replies; 15+ messages in thread
From: Jean Louis @ 2021-10-17  5:21 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: help-gnu-emacs

* Michael Heerdegen <michael_heerdegen@web.de> [2021-10-14 03:31]:
> I wrote:
> 
> > AFAICT COMMAND is also allowed to return a list of strings.
> 
> Apparently only my personal modified version supports that.  Do you
> think that would be a useful feature in general?

Yes. I find that useful and necessary to act upon directories based on
the user defined types. Examples are:

- Maildir type, with subdirectories being cur/tmp/new, it would open
  my email client or Emacs maildir package that I use;

- DVD type, when directory has VIDEO_TS and AUDIO_TS to play it with
  vlc or mpv player;

- Directory is for the archived website, and contains user defined
  string, it should be opened by browser.

- In my system Hyperscope, directories are forgotten, but are related
  to a list of different other items. Each directory has its ID
  number. When entering such directory I would rather like to enter
  into the Hyperscope full list of items. By using string recognition
  of directory or function to recognize string, I could invoke the
  function. 

- Some directories include pictures, videos, and maybe I like to open
  it in a faster picture viewer than what is Emacs.



-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



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

* Re: How to setup default program to launch directory?
  2021-10-14  0:18 ` Michael Heerdegen
  2021-10-14  0:30   ` Michael Heerdegen
@ 2021-10-17  5:32   ` Jean Louis
  2021-10-17  9:52     ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-10-18  7:02     ` Michael Heerdegen
  1 sibling, 2 replies; 15+ messages in thread
From: Jean Louis @ 2021-10-17  5:32 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: help-gnu-emacs

* Michael Heerdegen <michael_heerdegen@web.de> [2021-10-14 03:19]:
> Jean Louis <bugs@gnu.support> writes:
> 
> > I would like to launch programs on directories, is there any way to
> > set it up by default? This is also useful to launch videos on
> > directory. 
> 
> In each entry (REGEXP COMMAND...) in `dired-guess-shell-alist-user',
> COMMAND
> 
> | can either be a string or a Lisp expression that evaluates to a
> | string.  If this expression needs to consult the name of the file for
> | which the shell commands are being requested, it can access that file
> | name as the variable `file'.
> 
> (quoting from the docstring).  This is what you want to use.  Use a
> catchall REGEXP and make COMMAND an expression that returns something
> for directories, and nil else.  AFAICT COMMAND is also allowed to return
> a list of strings.
> 
> I made it so that the expression also looks inside the directory, and
> when it's full of images or media files, I return appropriate
> viewers.

I have made regexp to be: . 

and expression to be "(rcd-open-dir file)"

Though I find it not logical to have to put Lisp expression in quotes.

And I am trying to use this one.

(defun rcd-open-dir (file)
  "vlc")

but it says "exited abnormally" and I cannot see error messages.

Please show me example how you deal with it.

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



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

* Re: How to setup default program to launch directory?
  2021-10-17  5:32   ` Jean Louis
@ 2021-10-17  9:52     ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-10-17  9:59       ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-10-17 18:56       ` Jean Louis
  2021-10-18  7:02     ` Michael Heerdegen
  1 sibling, 2 replies; 15+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-10-17  9:52 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

> And I am trying to use this one.
>
> (defun rcd-open-dir (file)
>   "vlc")
>
> but it says "exited abnormally" and I cannot see
> error messages.
>
> Please show me example how you deal with it.

What are you trying to do?

Open all files of a certain type in a directory with a program
from dired?

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: How to setup default program to launch directory?
  2021-10-17  9:52     ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-10-17  9:59       ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-10-17 14:57         ` [External] : " Drew Adams
  2021-10-17 18:58         ` Jean Louis
  2021-10-17 18:56       ` Jean Louis
  1 sibling, 2 replies; 15+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-10-17  9:59 UTC (permalink / raw)
  To: help-gnu-emacs

You can get the files of a directory like this.

Then sort by extension and have an association list get you
a program for that extension ...

Maybe?

(require 'seq)

(defun dir-common-files (&optional dir)
  "Get a list of all files in the working directory."
  (let*((all-files (directory-files (or dir default-directory)))
        (files     (seq-difference all-files '("." ".."))) )
    files) )
;; (dir-common-files)
-- 
underground experts united
https://dataswamp.org/~incal




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

* RE: [External] : Re: How to setup default program to launch directory?
  2021-10-17  9:59       ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-10-17 14:57         ` Drew Adams
  2021-10-17 15:19           ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-10-17 18:58         ` Jean Louis
  1 sibling, 1 reply; 15+ messages in thread
From: Drew Adams @ 2021-10-17 14:57 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: 'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'

[-- Attachment #1: Type: text/plain, Size: 1129 bytes --]

> (require 'seq)
> (defun dir-common-files (&optional dir)
>   "Get a list of all files in the working directory."
>   (let*((all-files (directory-files (or dir default-directory)))
>         (files     (seq-difference all-files '("." ".."))) )
>     files) )

(directory-files (or  dir default-directory)
                 nil
                 "[^.]\\|\\.\\.\\.")
___

`C-h f directory-files':

directory-files is a built-in function in 'C source code'.

(directory-files DIRECTORY &optional FULL MATCH NOSORT)
                                          ^^^^^
Return a list of names of files in DIRECTORY.
There are three optional arguments:
If FULL is non-nil, return absolute file names.  Otherwise return names
 that are relative to the specified directory.
If MATCH is non-nil, mention only file names that match the regexp MATCH.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
If NOSORT is non-nil, the list is not sorted--its order is unpredictable.
 Otherwise, the list returned is sorted with `string-lessp'.
 NOSORT is useful if you plan to sort the result yourself.

[-- Attachment #2: winmail.dat --]
[-- Type: application/ms-tnef, Size: 13623 bytes --]

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

* Re: [External] : Re: How to setup default program to launch directory?
  2021-10-17 14:57         ` [External] : " Drew Adams
@ 2021-10-17 15:19           ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 15+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-10-17 15:19 UTC (permalink / raw)
  To: help-gnu-emacs

Drew Adams wrote:

>> (require 'seq)
>> (defun dir-common-files (&optional dir)
>>   "Get a list of all files in the working directory."
>>   (let*((all-files (directory-files (or dir default-directory)))
>>         (files     (seq-difference all-files '("." ".."))) )
>>     files) )
>
> (directory-files (or  dir default-directory)
>                  nil
>                  "[^.]\\|\\.\\.\\.")

OK, thanks!

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: How to setup default program to launch directory?
  2021-10-17  9:52     ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-10-17  9:59       ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-10-17 18:56       ` Jean Louis
  2021-10-18 16:36         ` Emanuel Berg via Users list for the GNU Emacs text editor
  1 sibling, 1 reply; 15+ messages in thread
From: Jean Louis @ 2021-10-17 18:56 UTC (permalink / raw)
  To: help-gnu-emacs

* Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2021-10-17 12:53]:
> Jean Louis wrote:
> 
> > And I am trying to use this one.
> >
> > (defun rcd-open-dir (file)
> >   "vlc")
> >
> > but it says "exited abnormally" and I cannot see
> > error messages.
> >
> > Please show me example how you deal with it.
> 
> What are you trying to do?
> 
> Open all files of a certain type in a directory with a program
> from dired?

You missed examples I have given:

- If directory is DVD copy, I need to open it with video player or
  enter inside if it is not;

- If directory is Maildir, I wish to open it in terminal, with Mutt,
  or in Emacs terminal or by using Emacs Maildir package;

- If directory is related to many other objects, I wish to open
  database showing me all other objects;

Don't you play DVD directories with vlc?

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



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

* Re: How to setup default program to launch directory?
  2021-10-17  9:59       ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-10-17 14:57         ` [External] : " Drew Adams
@ 2021-10-17 18:58         ` Jean Louis
  1 sibling, 0 replies; 15+ messages in thread
From: Jean Louis @ 2021-10-17 18:58 UTC (permalink / raw)
  To: help-gnu-emacs

* Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2021-10-17 13:01]:
> You can get the files of a directory like this.
> 
> Then sort by extension and have an association list get you
> a program for that extension ...
> 
> Maybe?
> 
> (require 'seq)
> 
> (defun dir-common-files (&optional dir)
>   "Get a list of all files in the working directory."
>   (let*((all-files (directory-files (or dir default-directory)))
>         (files     (seq-difference all-files '("." ".."))) )
>     files) )
> ;; (dir-common-files)

If I can add that to `dired-guess-shell-alist-user' then yes. Did you
use it there? I want to add function in that variable.


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



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

* Re: How to setup default program to launch directory?
  2021-10-17  5:32   ` Jean Louis
  2021-10-17  9:52     ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-10-18  7:02     ` Michael Heerdegen
  1 sibling, 0 replies; 15+ messages in thread
From: Michael Heerdegen @ 2021-10-18  7:02 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis <bugs@gnu.support> writes:

> I have made regexp to be: .
>
> and expression to be "(rcd-open-dir file)"
>
> Though I find it not logical to have to put Lisp expression in quotes.
>
> And I am trying to use this one.
>
> (defun rcd-open-dir (file)
>   "vlc")
>
> but it says "exited abnormally" and I cannot see error messages.
>
> Please show me example how you deal with it.

See the definition of `dired-guess-shell-alist-default' for some
examples involving expression type COMMANDs.

I can't tell what went wrong in your case without seeing the complete
code.  Maybe you just forgot to quote your expression so that it already
got eval'ed while loading?

Michael.



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

* Re: How to setup default program to launch directory?
  2021-10-17 18:56       ` Jean Louis
@ 2021-10-18 16:36         ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-10-18 17:14           ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 15+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-10-18 16:36 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

> You missed examples I have given:
>
> - If directory is DVD copy, I need to open it with video
>   player or enter inside if it is not;
>
> - If directory is Maildir, I wish to open it in terminal,
>   with Mutt, or in Emacs terminal or by using Emacs Maildir
>   package;
>
> - If directory is related to many other objects, I wish to
>   open database showing me all other objects;

I think you need different functions for these, assigned to
different keys, if you don't want that you'd need one big
function that would perhaps based on the directory file name
take proper action - even so it can be beneficial to have it
call different functions ... it will be easier (and better) to
write it that way as well.

> Don't you play DVD directories with vlc?

No, I don't use DVDs, and I use mpv for Hollywood movies and
Australian Survivor episodes ...

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: How to setup default program to launch directory?
  2021-10-18 16:36         ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-10-18 17:14           ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 15+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-10-18 17:14 UTC (permalink / raw)
  To: help-gnu-emacs

>> Don't you play DVD directories with vlc?
>
> No, I don't use DVDs, and I use mpv for Hollywood movies and
> Australian Survivor episodes ...

And Japanese movies ... sometimes.

I just today read "Nausicaä of the Valley of the Wind", a late
80s manga by Hayao Miyazaki - who then directed
"Princess Mononoke" (1997) and "Spirited Away" (2001) - not
a bad manga in that "fuzzy" style of his, still there's
something detached about it ... or maybe it is just me.

  https://dataswamp.org/~incal/FILM

How many movies are listed in that file?

  (how-many "^ \\{6\\}[[:alnum:]]" (point-min)) ; 94 :)

So yes, in the other thread I said that tools should work no
matter the formating, I guess this is the exception that
proves the rule ;)

-- 
underground experts united
https://dataswamp.org/~incal




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

end of thread, other threads:[~2021-10-18 17:14 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-13 21:10 How to setup default program to launch directory? Jean Louis
2021-10-13 22:02 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-14  0:18 ` Michael Heerdegen
2021-10-14  0:30   ` Michael Heerdegen
2021-10-17  5:21     ` Jean Louis
2021-10-17  5:32   ` Jean Louis
2021-10-17  9:52     ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-17  9:59       ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-17 14:57         ` [External] : " Drew Adams
2021-10-17 15:19           ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-17 18:58         ` Jean Louis
2021-10-17 18:56       ` Jean Louis
2021-10-18 16:36         ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-18 17:14           ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-18  7:02     ` Michael Heerdegen

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.