Save As Dialog
Some users might appreciate the traditional Save As Dialog, here is a rough implementation, based on https://www.emacswiki.org/emacs/MacOSTweaks via Apple-Script, also implementing the Open Dialog. It is replacing the corresponding section in the init.el as below:
;; Things you'd expect from macOS app. (defun mac-open-file (filename &optional wildcards) (interactive (let ((last-nonmenu-event nil)) (find-file-read-args "Find existing file: " t)) ) ; (find-file-existing filename wildcards) (find-file-existing filename) )
(defun mac-save-file-as () (interactive) (let ((file (do-applescript "try POSIX path of (choose file name with prompt "Save As...") end try")))
(if (not (equal file "")) (write-file file) (beep)) ))
(defun mac-save-file () (interactive) (if (buffer-modified-p) (if (equal buffer-file-name nil) (let ((file (do-applescript "try POSIX path of (choose file name with prompt "Save As...") end try"))) (if (not (equal file "")) (write-file file) (beep)) ) (save-buffer) )))
(global-set-key (kbd "s-o") 'mac-open-file) ;; open (global-set-key (kbd "s-s") 'mac-save-file) ;; save (global-set-key (kbd "s-S") 'mac-save-file-as) ;; save as (global-set-key (kbd "s-q") 'save-buffers-kill-emacs) ;; quit (global-set-key (kbd "s-a") 'mark-whole-buffer) ;; select all ;; (global-set-key (kbd "s-z") 'undo)
Seems like some escape characters are missing. But I'm not sure if it's a good idea to override the regular saving and opening mechanisms. Maybe provide these functions without hotkeys for now. Or augment them with alt:
-
M-s-oto open -
M-s-sto save -
M-S-s-sto save as
?..