Mercurial > hg > dotemacs
changeset 210:98ea617c263a
add jordi-find-file-with-mode
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Tue, 10 Aug 2021 14:21:00 -0400 |
parents | e51a4d0ee855 |
children | f6ba3ca3dbd4 |
files | dotemacs.el |
diffstat | 1 files changed, 14 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/dotemacs.el +++ b/dotemacs.el @@ -90,6 +90,20 @@ (setq org-confirm-babel-evaluate nil) ;; And show me the image right there once you're done. + +;; Thanks to dale of #emacs +(defun jordi-find-file-with-mode (mode) + "Calls `find-file' to open a file with the given MODE." + (interactive (list (let ((default "fundamental-mode")) + (intern (completing-read + (format-prompt "Mode" default) + obarray + (lambda (sym) + (string-match-p "-mode\\'" (symbol-name sym))) + t nil nil default nil))))) + (cl-letf (((symbol-function 'set-auto-mode) + (lambda (&rest _) (set-auto-mode-0 mode)))) + (call-interactively 'find-file))) (add-hook 'org-babel-after-execute-hook 'org-display-inline-images)