30

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 '(("\\.pdf\\'" "evince" (file))))


19

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 ...


16

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: (require 'recentf) (defun ido-recentf-open () "Use `ido-completing-read' to find a recent file." (interactive) (if (find-file (ido-...


11

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. ...


10

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.


7

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 predicate 'stringp'. Documentation: Name of ...


6

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 ...


6

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 confirmation is requested. When nil, never request confirmation. You can customize this variable. This variable was introduced, or its default value was ...


6

(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 (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 (defun ...


6

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) default-directory))) (ivy-add-actions #'counsel-file-jump '(("d" my/ivy-open-dir-action "open in dired"))) To invoke it, you can search normally and ...


6

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 ...


5

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 C-...


5

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 ...


5

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) ...


5

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 ...


5

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. 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 ...


5

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-string COMMAND) Execute shell command COMMAND and return its output as a string. For example, on my machine, your shell command gives (let ((default-...


5

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.


5

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 (file-directory-p file) (string-match "\\.py[co]$" file))) (directory-files default-directory)) It maybe that you have already the (require 'cl-...


5

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 ...


5

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 ...


5

Asuming that C-x C-f is bound to ido-find-file you drop back to the non-Ido version by typing C-x C-f again or just C-f. This will allow you to create the file you want without Ido interfence.


4

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-...


4

I wrote a function and added to find-file-not-found-functions (defun srs-set-new-sql-file-coding-system () (with-current-buffer (current-buffer) (if (string-match "\\.d?sql\\'" buffer-file-name) (setq buffer-file-coding-system 'utf-8-with-signature-dos) nil))) (add-hook 'find-file-not-found-functions 'srs-set-new-sql-file-coding-system)


4

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 ...


4

You could use this version of the function: (defun journal-entry () (interactive) (let* ((daily-name (format-time-string "%Y-%m-%d)")) (journal-path "~/Dropbox (Personal)/journal/") (journal-file (concat journal-path daily-name ".md"))) (find-file journal-file) (unless (file-exists-p journal-file) (insert "JOURNAL" "\n" ...


4

Elisp regular expressions are hard to read, hard to get right and even harder to maintain. Here are two alternative approaches: foreign-regexp.el -- https://github.com/k-talo/foreign-regexp.el Allows you to use regexps just like in perl, python, javascript or ruby. This is not a widely used or tested package but great if you really do not want to deal with ...


4

The built-in library saveplace.el contains a commentary that states: ;; Automatically save place in files, so that visiting them later ;; (even during a different Emacs session) automatically moves point ;; to the saved position, when the file is first found. Uses the ;; value of buffer-local variable save-place to determine whether to ;; save position or ...


4

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." (interactive "D") (mapc #'find-file (...


4

The general answer is find-file(-other-window): C-x C-f (C-x 4 f). But it helps to use Dired (C-x 4 d) in the directory you want. That sets the default-directory, so C-x C-f looks for files in that directory when you are in that Dired buffer. You can customize option completion-category-overrides to get the kind(s) of file-name pattern matching you want. ...


Only top voted, non community-wiki answers of a minimum length are eligible