Emacs | Getting More Efficient With Org Mode Attachments | Efficient!

Emacs | Getting More Efficient With Org Mode Attachments | Efficient!

Chris Maiorana

1 год назад

2,071 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@PeterPrevos
@PeterPrevos - 02.03.2023 09:18

When in dired, just press ! top open a file in openoffice etc. You can also define external programs for file types.

Ответить
@m.espina
@m.espina - 17.01.2023 23:18

In Spacemacs theese two functions implement exactly what you want:

(defun spacemacs//open-in-external-app (file-path)
"Open `file-path' in external application."
(cond
((spacemacs/system-is-mswindows)
(w32-shell-execute "open" (replace-regexp-in-string "/" "\\\\" file-path)))
((spacemacs/system-is-mac) (shell-command (format "open \"%s\"" file-path)))
((spacemacs/system-is-linux) (let ((process-connection-type nil))
(start-process "" nil "xdg-open" file-path)))))

(defun spacemacs/open-file-or-directory-in-external-app (arg)
"Open current file in external application.
If the universal prefix argument is used then open the folder
containing the current file by the default explorer."
(interactive "P")
(if arg
(spacemacs//open-in-external-app (expand-file-name default-directory))
(let ((file-path (if (derived-mode-p 'dired-mode)
(dired-get-file-for-visit)
buffer-file-name)))
(if file-path
(spacemacs//open-in-external-app file-path)
(message "No file associated to this buffer.")))))

Calling spacemacs/open-file-or-directory-in-external-app over a filename in Dired, the file is opened with the default application associated with its type. If the current position in Dired is a directory (including . or ..), the file manager will open on that directory.

Ответить
@rashie
@rashie - 22.12.2022 18:22

👍👍

Ответить
@dsds-rj9rg
@dsds-rj9rg - 17.12.2022 10:36

Might be worth looking into calling xdg-open from the terminal or making some kind of binding to call it on the file at cursor in dired

Ответить
@torext5585
@torext5585 - 15.12.2022 04:03

If one uses consult, then M-x consult-file-externally is also an option

Ответить
@sanestebanalpoder
@sanestebanalpoder - 13.12.2022 02:01

Hi, If I want to run a external application from dired, I type "!" over file in dired and I type name of application (libreoffice). It will open that file externally using that application. Emacs will be frozen until external app is closed. To avoid that, you can choose "&" instead of "!".

And also, you can set a default external application per extension. If configure this variable in your configuration file:

(require 'dired-x)
(setq dired-guess-shell-alist-user '(("\\.avi\\'" "totem")
("\\.doc\\'" "libreoffice")
("\\.docx\\'" "libreoffice")
("\\.mkv\\'" "totem")
("\\.mp3\\'" "totem")
("\\.mp4\\'" "totem")
("\\.odt\\'" "libreoffice")
("\\.pdf\\'" "evince")
("\\.ppt\\'" "libreoffice")
("\\.pptx\\'" "libreoffice")
("\\.webm\\'" "totem")
("\\.xls\\'" "libreoffice")))

With this config you type "!" or "&" and later ENTER because libreoffice is default for .odt files.

Other alternative is using shell-command (M-!) from dired, and type "libreoffice file.odf". It has autocompletion and use relative path from dired.

Both works for me.

Thank you for your videos!

Ответить