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) (global-set-key (kbd "C-*") 'universal-argument)
(define-key universal-argument-map (kbd "C-*") 'universal-argument-more) (define-key universal-argument-map (kbd "C-*") 'universal-argument-more)
(map! :leader "u" 'evil-prev-buffer (defun xah-open-in-external-app (&optional @fname)
:leader "i" 'evil-next-buffer "Open the current file or dired marked files in external app.
:leader "bq" 'doom/save-and-kill-buffer When called in emacs lisp, if @fname is given, open that.
:leader "d" 'dragon 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 ;; Buffer-local font resizing
:n "M-C-=" 'text-scale-increase :n
:n "M-C--" 'text-scale-decrease "M-C-=" 'text-scale-increase
"M-C--" 'text-scale-decrease
;; Frame-local font resizing ;; Frame-local font resizing
:n "C-=" 'doom/increase-font-size "C-=" 'doom/increase-font-size
:n "C--" 'doom/decrease-font-size "C--" 'doom/decrease-font-size
) )
;;;; GLOBAL SETUP ;;;; GLOBAL SETUP
@ -273,9 +308,9 @@
; (add-to-list 'org-file-apps '(system . "setsid -w xdg-open %s")) ; (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 ;; 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-done 'time
(setq org-log-into-drawer t) org-log-into-drawer t
(setq org-treat-insert-todo-heading-as-state-change t) org-treat-insert-todo-heading-as-state-change t)
;;;; PACKAGES ;;;; PACKAGES