config/doom: add xah-open-in-external-app to SPC-#

This commit is contained in:
xeruf 2021-05-07 12:32:04 +02:00
parent 5dce61fb45
commit c14ab62e3e
1 changed files with 46 additions and 11 deletions

View File

@ -45,16 +45,51 @@
(global-set-key (kbd "C-*") 'universal-argument)
(define-key universal-argument-map (kbd "C-*") 'universal-argument-more)
(map! :leader "u" 'evil-prev-buffer
:leader "i" 'evil-next-buffer
:leader "bq" 'doom/save-and-kill-buffer
:leader "d" 'dragon
(defun xah-open-in-external-app (&optional @fname)
"Open the current file or dired marked files in external app.
When called in emacs lisp, if @fname is given, open that.
URL `http://ergoemacs.org/emacs/emacs_dired_open_file_in_ext_apps.html'
Version 2019-11-04 2021-02-16"
(interactive)
(let* (
($file-list
(if @fname
(progn (list @fname))
(if (string-equal major-mode "dired-mode")
(dired-get-marked-files)
(list (buffer-file-name)))))
($do-it-p (if (<= (length $file-list) 5)
t
(y-or-n-p "Open more than 5 files? "))))
(when $do-it-p
(cond
((string-equal system-type "windows-nt")
(mapc
(lambda ($fpath)
(shell-command (concat "PowerShell -Command \"Invoke-Item -LiteralPath\" " "'" (shell-quote-argument (expand-file-name $fpath )) "'")))
$file-list))
((string-equal system-type "darwin")
(mapc
(lambda ($fpath)
(shell-command
(concat "open " (shell-quote-argument $fpath)))) $file-list))
((string-equal system-type "gnu/linux")
(mapc
(lambda ($fpath) (let ((process-connection-type nil))
(start-process "" nil "xdg-open" $fpath))) $file-list))))))
(map! :leader
"u" 'evil-prev-buffer
"i" 'evil-next-buffer
"bq" 'doom/save-and-kill-buffer
"d" 'dragon
"#" 'xah-open-in-external-app
;; Buffer-local font resizing
:n "M-C-=" 'text-scale-increase
:n "M-C--" 'text-scale-decrease
:n
"M-C-=" 'text-scale-increase
"M-C--" 'text-scale-decrease
;; Frame-local font resizing
:n "C-=" 'doom/increase-font-size
:n "C--" 'doom/decrease-font-size
"C-=" 'doom/increase-font-size
"C--" 'doom/decrease-font-size
)
;;;; GLOBAL SETUP
@ -273,9 +308,9 @@
; (add-to-list 'org-file-apps '(system . "setsid -w xdg-open %s"))
;; Automated logging for todos - https://stackoverflow.com/questions/12262220/add-created-date-property-to-todos-in-org-mode/52815573#52815573
(setq org-log-done 'time)
(setq org-log-into-drawer t)
(setq org-treat-insert-todo-heading-as-state-change t)
(setq org-log-done 'time
org-log-into-drawer t
org-treat-insert-todo-heading-as-state-change t)
;;;; PACKAGES