Discussion:
File Browser to show only one extension?
(too old to reply)
RonB
2020-02-03 14:02:29 UTC
Permalink
Hi,

At this point I want to use Emacs for only one file type with the extension
".fountain." The following is in my command line when clicking an icon on
the desktop (using Linux Mint Mate 19.3)...

/usr/bin/emacs25 %F /home/myname/Documents/scripts

What this does is opens Emacs and (in one window) lists all the files in the
scripts sub-directory. Is there way to tell Emacs to just show the files that
end with ".fountain"?

Thanks for any pointers.
--
"People are innocent until alleged to be involved in some
kind of criminal activity." — John Brennan, ex-CIA Director
Javier
2020-02-04 00:48:47 UTC
Permalink
Post by RonB
At this point I want to use Emacs for only one file type with the extension
".fountain." The following is in my command line when clicking an icon on
the desktop (using Linux Mint Mate 19.3)...
/usr/bin/emacs25 %F /home/myname/Documents/scripts
What this does is opens Emacs and (in one window) lists all the files in the
scripts sub-directory. Is there way to tell Emacs to just show the files that
end with ".fountain"?
Have a look at

M-: (info "(dired-x) Omitting Variables")

This would omit all filenames that do not end in 'n'

(dired-omit-files "[^n]$")
(add-hook 'dired-mode-hook
(lambda ()
(dired-omit-mode 1)
))
Michael Heerdegen
2020-02-04 12:35:13 UTC
Permalink
Post by Javier
Post by RonB
Is there way to tell Emacs to just show the
files that
end with ".fountain"?
Have a look at
M-: (info "(dired-x) Omitting Variables")
Yes, that also came to my mind first.
Post by Javier
This would omit all filenames that do not end in 'n'
(dired-omit-files "[^n]$")
^^^

Isn't there a `setq' missing (`dired-omit-files' is a variable)?
Post by Javier
(add-hook 'dired-mode-hook
(lambda ()
(dired-omit-mode 1)
))
Of course this will effect the whole emacs session. The answer somewhat
depends on how the OP wants to use the dired buffer and the session.

An alternative would be to mark by extension (* .), toggle marks (t) and
kill the marked files from the view (k). That could be done from Lisp,
too, of course. You need to require "dired-x" to do that. It's part of
Emacs but not loaded by default.

It's also possible to invoke `dired' from Lisp with an explicit
precalculated list of files instead of a directory. This approach would
make it unnecessary to mess with dired options.


Michael.
RonB
2020-02-04 15:33:48 UTC
Permalink
Post by Michael Heerdegen
Post by Javier
Post by RonB
Is there way to tell Emacs to just show the
files that
end with ".fountain"?
Have a look at
M-: (info "(dired-x) Omitting Variables")
Yes, that also came to my mind first.
Post by Javier
This would omit all filenames that do not end in 'n'
(dired-omit-files "[^n]$")
^^^
Isn't there a `setq' missing (`dired-omit-files' is a variable)?
Post by Javier
(add-hook 'dired-mode-hook
(lambda ()
(dired-omit-mode 1)
))
Of course this will effect the whole emacs session. The answer somewhat
depends on how the OP wants to use the dired buffer and the session.
An alternative would be to mark by extension (* .), toggle marks (t) and
kill the marked files from the view (k). That could be done from Lisp,
too, of course. You need to require "dired-x" to do that. It's part of
Emacs but not loaded by default.
It's also possible to invoke `dired' from Lisp with an explicit
precalculated list of files instead of a directory. This approach would
make it unnecessary to mess with dired options.
Michael.
Thanks. I've copied this all down (appended to the past post in Simplenote)
and will study it when I get time. I'll admit that (right now) it looks kind
of like gobble-dee-gook to me, but that's only because I'm ignorant of all
things Emacs and Lisp. I can see that Emacs is an extremely powerful
application.

Again, thank you.
--
"People are innocent until alleged to be involved in some
kind of criminal activity." — John Brennan, ex-CIA Director
Michael Heerdegen
2020-02-04 16:13:12 UTC
Permalink
Post by RonB
Thanks. I've copied this all down (appended to the past post in
Simplenote) and will study it when I get time. I'll admit that (right
now) it looks kind of like gobble-dee-gook to me, but that's only
because I'm ignorant of all things Emacs and Lisp. I can see that
Emacs is an extremely powerful application.
Here is something to start with:

(dired (cons (generate-new-buffer-name "your-name-here")
(directory-files "/your/dir/" nil "\\.fontain$")))

That creates a separate dired buffer with all fontain files in
"/your/dir/". AFAIK, toggling sorting (s) doesn't work in such buffers,
though, instead, you can sort the specified file list in a way you want.

Michael.
RonB
2020-02-04 15:25:11 UTC
Permalink
Post by Javier
Post by RonB
At this point I want to use Emacs for only one file type with the extension
".fountain." The following is in my command line when clicking an icon on
the desktop (using Linux Mint Mate 19.3)...
/usr/bin/emacs25 %F /home/myname/Documents/scripts
What this does is opens Emacs and (in one window) lists all the files in the
scripts sub-directory. Is there way to tell Emacs to just show the files that
end with ".fountain"?
Have a look at
M-: (info "(dired-x) Omitting Variables")
This would omit all filenames that do not end in 'n'
(dired-omit-files "[^n]$")
(add-hook 'dired-mode-hook
(lambda ()
(dired-omit-mode 1)
))
Thanks! I've copied your post into Simplenote and will study it to try to
figure out what you're doing. (I think, when I get time, I'll probably work
through some Emacs tutorials.) Right now, however, I'm just using Emacs for
the one purpose.

Meanwhile, since I know a little more about shell scripts than Emacs (which
is only slightly less than nothing), I found a solution that seems to work
okay without having to mess with Emacs.

A shell script I named "emf" ("em" for Emacs and "f" for fountain).

#!/bin/bash
cd ~/Documents/scripts
ls -tl *.fountain
read -p 'file: ' uservar
emacs $uservar".fountain" &
exit

Since there should only be (maybe) ten to fifteen Fountain files at the most
in my working directory at any one time, this should be sufficient. I also
like the new files showing up at the top. Fountain-Mode is really nice in
that all you have to do is open a ".fountain" file (or create one) to
automatically be put in Fountain-Mode.

I run the above script with "source" (source emf) so it will exit out of the
terminal when Emacs starts.

Thanks again.
--
"People are innocent until alleged to be involved in some
kind of criminal activity." — John Brennan, ex-CIA Director
RonB
2020-02-05 20:47:18 UTC
Permalink
Post by RonB
Post by Javier
Post by RonB
At this point I want to use Emacs for only one file type with the extension
".fountain." The following is in my command line when clicking an icon on
the desktop (using Linux Mint Mate 19.3)...
/usr/bin/emacs25 %F /home/myname/Documents/scripts
What this does is opens Emacs and (in one window) lists all the files in the
scripts sub-directory. Is there way to tell Emacs to just show the files that
end with ".fountain"?
Have a look at
M-: (info "(dired-x) Omitting Variables")
This would omit all filenames that do not end in 'n'
(dired-omit-files "[^n]$")
(add-hook 'dired-mode-hook
(lambda ()
(dired-omit-mode 1)
))
Thanks! I've copied your post into Simplenote and will study it to try to
figure out what you're doing. (I think, when I get time, I'll probably work
through some Emacs tutorials.) Right now, however, I'm just using Emacs for
the one purpose.
Meanwhile, since I know a little more about shell scripts than Emacs (which
is only slightly less than nothing), I found a solution that seems to work
okay without having to mess with Emacs.
A shell script I named "emf" ("em" for Emacs and "f" for fountain).
#!/bin/bash
cd ~/Documents/scripts
ls -tl *.fountain
read -p 'file: ' uservar
emacs $uservar".fountain" &
exit
Since there should only be (maybe) ten to fifteen Fountain files at the most
in my working directory at any one time, this should be sufficient. I also
like the new files showing up at the top. Fountain-Mode is really nice in
that all you have to do is open a ".fountain" file (or create one) to
automatically be put in Fountain-Mode.
I run the above script with "source" (source emf) so it will exit out of the
terminal when Emacs starts.
Thanks again.
I've refined the process a little by automatically opening Atril with Emacs
(after choosing a file). This works well for what I need. (Made a short
video in Vokoscreen to show what I'm talking about.) The new script looks
like this...

#!/bin/bash
cd ~/Documents/scripts
clear
lst lfount # or ls -tl *.fountain
read -p 'file: ' uservar
wrxr $uservar >2 errors.txt
em $uservar 2> errors.txt & # or emacs $uservar".fountain"
exit

(Calling a couple other scripts here, but doing the same as above (put what
the scripts do in the remarks). The X Windows applications throw errors when
started from a terminal, so I just redirect them to a file (though it
probably doesn't matter since I'm closing the terminal anyhow)).

https://drive.google.com/open?id=1JoXrJpkQVj0LezVGnS4JiFPSrGcgzy5M
--
The fabulous Latitude D430, running
Linux Mint Mate 19.3 on 2GBs of RAM
Continue reading on narkive:
Loading...