Try openwith. The following code will enable it, and allow you to open PDFs with evince (change to your favorite PDF viewer):
(setq openwith-associations '(("\\.pdf\\'" "evince" (file))))
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. Emacs is now my favourite PDF reader. You can also bookmark specific PDF page by using Bookmark(+).
EDIT: If you use helm and want to use external program, helm ...
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 your init-file:
(defun ido-recentf-open ()
"Use `ido-completing-read' to find a recent file."
(if (find-file (ido-...
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) in option dired-guess-shell-alist-user. And if you use Emacs on MS Windows, then it is worthwhile knowing how to open a file using Windows file associations.
The variable is large-file-warning-threshold. Documentation:
large-file-warning-threshold is a variable defined in `files.el'.
Its value is 10000000
Maximum size of file above which a confirmation is requested.
When nil, never request confirmation.
You can customize this variable.
This variable was introduced, or its default value was ...
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 buffer-local when set. This
variable is safe as a file local variable if its value satisfies the
Documentation: Name of ...
(get-file-buffer filename) returns the buffer visiting filename, or nil if there is none.
Edit: justbur proposes using (find-buffer-visiting file) instead, as it also works when the buffer has a different name than the file.
So one solution would be sth in the lines of
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 documentation via C-h f ido-find-file. If you like that, M-x ido-mode will switch C-x C-f from calling find-file to ido-find-file.
counsel-find-file, from the ...
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 created. Otherwise the buffers are created but only one is displayed initially.
This does not open org files in subdirectories. To do that additionally use
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 the last most recent buffer, and then immediately switches to the new buffer.
In emacsclient, things work differently. If you kill all buffers created by that ...
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)
(dired (or (file-name-directory x)
'(("d" my/ivy-open-dir-action "open in dired")))
To invoke it, you can search normally and ...
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-use-filename-at-point 'guess)
For ivy/counsel users
Add the below to your config and then M-x counsel-find-file (which you can conveniently bind to C-x C-f) ...
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 option directory-abbrev-alist. That's what it is for. See the Emacs manual, node File Aliases.
The doc focuses on the use of directory-abbrev-alist with symbolic ...
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 back to what you want:
(add-hook 'find-file-hook #'(lambda () (setq default-directory (expand-file-name "~/"))))
However this does have the disadvantage of ...
This works for me:
'("/bin/.*[^/]\\'" . "Shell-Script")
[(lambda () (sh-mode))
("Default shell script: "
There are two issues here.
auto-insert can call functions as a part of the action, but for some reason it has to be a lambda form. (I wonder why it checks for lambda instead of calling ...
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’.
Execute shell command COMMAND and return its output as a string.
For example, on my machine, your shell command gives
Note that (?!.*pyc$) is regular expression syntax of perl (zero negative lookahead) that does not work in emacs.
You can use
(lambda (file) (or
(string-match "\\.py[co]$" file)))
It maybe that you have already the (require 'cl-...
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 have zero-width assertions in regular expressions. Also, you need to escape the parenthesis in Emacs regexp.
What does the regular expression match
It matches ...
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, Emacs doesn't know what you mean.
First, I'd try installing counsel via package-list-packages. If that doesn't fix the problem, or if counsel is already ...
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 in ‘ivy.el’.
Its value is ("../" "./")
Add this to the front of the list when completing file names.
Only "./" and "../" apply here. They ...
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 expression.
(defun open-org-files-recursively (dirname)
"Search DIRNAME recursively for org files, and open them all."
(mapc #'find-file (...
Have emacs read from stdin device and insert contents into *scratch* buffer.
$ fold -w80 myfile | emacs --insert /path/to/stdin
Note: You will need to update /path/to/stdin path
$ fold -w80 myfile | emacs --insert /dev/stdin
This answer was validated using:
emacs version: GNU Emacs 25.2.1
This question was used as a reference.
@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 ()
(let ((files (org-agenda-files))) (mapcar (lambda (x) (find-file x)) files)))
(this is his code, if you like this, please up-vote his comment)
Now you can add files to your agenda file list ...
As @grettke mentioned in the comments, this question is not specific to org mode. From what I understand you need a solution to quickly open any file from a "project".
If that's the case, you can try using the projectile package, also available through Melpa.
For projectile to work on your set of files, you need to define that set as being a part of a "...
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 a dired buffer with a hook:
(defun my/ido-ignore-file-at-point ()
"Disable ido-use-filename-at-point for the current buffer."
(when (bound-and-true-p ido-...
I wrote a function and added to find-file-not-found-functions
(defun srs-set-new-sql-file-coding-system ()
(if (string-match "\\.d?sql\\'" buffer-file-name)
(setq buffer-file-coding-system 'utf-8-with-signature-dos)
(add-hook 'find-file-not-found-functions 'srs-set-new-sql-file-coding-system)
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 assuming that you mean completion when using a file-finding command (e.g. C-x C-f), and not completion when in a shell buffer.)
In vanilla Emacs, if you set ...
You could use this version of the function:
(defun journal-entry ()
(let* ((daily-name (format-time-string "%Y-%m-%d)"))
(journal-path "~/Dropbox (Personal)/journal/")
(journal-file (concat journal-path daily-name ".md")))
(unless (file-exists-p journal-file)
(insert "JOURNAL" "\n" ...