40
votes
Accepted
How to use an external program as the default way to open PDFs from Emacs?
Try openwith. The following code will enable it, and allow you to open PDFs with evince (change to your favorite PDF viewer):
(require 'openwith)
(openwith-mode t)
(setq openwith-associations '(("\\....

Dan♦
- 31.1k
21
votes
How to use an external program as the default way to open PDFs from Emacs?
If you want to view PDF with many features (highlighting search, highlighting selection, annotate, content tree), use pdf-tools. As you can see in the demo, I can using Isearch with highlighting. ...
16
votes
Accepted
Recently opened files in ido-mode
Looking at the customization options for ido-mode (M-x customize-group RET ido RET), I don't see any options for enabling the cycling behavior you describe.
You can, however, add the following to ...
14
votes
Accepted
Is there a way to show/open a file from a URI/URL
M-x url-handler-mode
C-x C-f http://emacs.stackexchange.com/questions/21180/is-there-a-way-to-show-open-a-file-from-a-uri-url
This opens the HTML file of this stackexchange question in your Emacs.
12
votes
How to use an external program as the default way to open PDFs from Emacs?
You asked about find-file. In addition to what others (e.g., Dan) say about that, it is worthwhile to also know about opening files using an application associated with the file type (e.g. extension) ...
9
votes
Accepted
How to check, if a file is already visited?
(get-file-buffer filename) returns the buffer visiting filename, or nil if there is none.
https://www.gnu.org/software/emacs/manual/html_node/elisp/Buffer-File-Name.html
Edit: justbur proposes using ...
7
votes
Accepted
docview: suppress "File X is too large, really open?" confirmation
The variable is large-file-warning-threshold. Documentation:
large-file-warning-threshold is a variable defined in `files.el'.
Its value is 10000000
Documentation:
Maximum size of file above which a ...
7
votes
Accepted
Load all org files into buffers?
You can use wildcards with find-file:
C-x C-f ~/path/to/*.org RET
This will open all org files in /path/to/. You could also use find-file-other-frame to instantly display all the buffers that were ...
7
votes
Accepted
Setting default-directory does not change find-file directory
According to the documentation:
default-directory is a variable defined in ‘C source code’. Its value
is "~/" Local in buffer *scratch*; global value is nil
Automatically becomes permanently ...
7
votes
Accepted
Omit current and parent directories in Ivy find-file completion
When I'm opening a file I'd like . and .. to be omitted from the list of completion candidates.
This is what the user option ivy-extra-directories is for:
ivy-extra-directories is a variable defined ...
7
votes
How show recent files?
install counsel (https://oremacs.com/2015/04/09/counsel-completion/)
Run M-x counsel-recentf
Press C-c C-o to export the file list to a buffer
7
votes
Template for new file
See standard library auto-insert.el, which is part of Emacs. To use it, customize options auto-insert and auto-insert-directory, then do this:
(add-hook 'find-file-hook 'auto-insert)
auto-insert ...
7
votes
Find file in directory
It sounds like find-file, C-x C-f does what you want. There are more sophisticated options available for this kind of basic operation:
ido-find-file, which is built-in to Emacs. You can see the ...
6
votes
Accepted
Reloading files from disk in frame with emacsclient
Essentially, find-alternate-file kills the current buffer and immediately opens another file (creating a new buffer in its stead). Normally, this is fine. When the buffer is killed, Emacs switches to ...
6
votes
Switch buffer to the file path in current cursor position
For ido users
Add the below to your config and then C-x C-f (which should be executing ido-find-file automatically with ido-mode enabled) on such file paths will open those files directly.
(setq ido-...
6
votes
Accepted
Quickly open file by full path in clipboard
C-x C-f x 2 C-aC-yC-kenter
Pressing C-x C-f while inside ido-find-file will take you back into the normal find-file in which you can easily clear out all the input and yank your path into.
6
votes
Accepted
C-x C-f results in the error message: "Wrong type argument: commandp, counsel-find-file"
You have bound C-x C-f to the command counsel-find-file, which is part of the Counsel Package. Apparently, the counsel package is not getting loaded by your config files, so when you try to call it, ...
6
votes
Template for new file
At @Drew's suggestion, here's a short example of combining YASnippet and auto-insert to achieve dynamic or interactive boilerplate.
From my ~/.emacs.d/init.el:
;;{{{ yasnippet & auto-insert
(...
6
votes
Accepted
Open directory containing file during counsel-file-jump
You can create a new Ivy action that opens the directory of a file name selection. It can be done with:
(defun my/ivy-open-dir-action (x)
(interactive)
(dired (or (file-name-directory x)
...
6
votes
Accepted
ivy counsel find-file with similar name
Using C-M-j when you're at prompt line. Binds to ivy-immediate-done
As manual states it goes with current input instead the current candidate.
5
votes
Accepted
auto-insert a skeleton and run a function when creating a new file
This works for me:
(define-auto-insert
'("/bin/.*[^/]\\'" . "Shell-Script")
[(lambda () (sh-mode))
("Default shell script: "
"#!/bin/bash\n\n"
> _)])
There are two issues here.
...
5
votes
Accepted
Tell Dired to ignore file-at-point when invoking `ido-find-file` (`C-x C-f` in Ido mode)
If you are using ido-find-file and have configured ido to use the filename at point (e.g. you have ido-use-filename-at-point set to t or 'guess), you can prevent ido from using the name at point from ...
5
votes
Load all org files into buffers?
@Lawlist gave a nice snippet of code in his comment. You can assign a function to load all org files via:
(defun my/open-all-org-agenda-files ()
(interactive)
(let ((files (org-agenda-files))) (...
5
votes
Accepted
Can I stop Emacs from resetting default-directory every time I open a file?
default-directory is a buffer local variable which can be set by all sorts of things although it is always set on loading a file. The simplest dumb solution is to use the find-file-hook and set it ...
5
votes
Accepted
Running out of L:/ etters: shortcut for path needed
I'd echo the suggestion of using bookmarks.
You can use environment variables (define your own, to correspond to whatever directory prefixes you want).
You can define directory abbreviations, using ...
5
votes
Accepted
Is there a way to make emacs fully complete a filename and cycle through the completions by hitting tab?
Not sure what you mean by a full file name. Do you mean that you want to see absolute file names as completion candidates, instead of relative names?
(Based on your use of the find-file tag, I'm ...
5
votes
Accepted
How to write a custom find-file function
You can use shell-command-to-string to get a shell command's output. From C-h f shell-command-to-string:
shell-command-to-string is a compiled Lisp function in ‘simple.el’.
(shell-command-to-...
5
votes
Accepted
Regex for any file not ends with
Note that (?!.*pyc$) is regular expression syntax of perl (zero negative lookahead) that does not work in emacs.
You can use
(require 'cl-lib)
(cl-remove-if
(lambda (file) (or
(...
5
votes
Regex for any file not ends with
The way you intended this to be done:
(find-lisp-find-files "." "\\(^..?\\|py[^co]\\|[^p]..\\|.[^y].\\)$")
which, probably requires some explanation.
Why your attempt didn't work
Emacs doesn't ...
5
votes
Accepted
Function to open all Org files in a folder recursively
Here is a solution for org files. I wouldn't recognise a Fountain file if I saw one, so you'd have to provide that one yourself. The second argument to directory-files-recursively is a regular ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
find-file × 144files × 16
helm × 10
completion × 10
ivy × 10
buffers × 7
tramp × 6
ido × 6
ido-find-file × 6
spacemacs × 5
dired × 5
shell × 5
minibuffer × 5
counsel × 5
directories × 5
key-bindings × 4
init-file × 4
filenames × 4
ffap × 4
evil × 3
hooks × 3
performance × 3
icicles × 3
template × 3
large-files × 3