castlemacs icon indicating copy to clipboard operation
castlemacs copied to clipboard

Save As Dialog

Open jkhsch opened this issue 5 years ago • 1 comments

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)

jkhsch avatar Jun 08 '20 21:06 jkhsch

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-o to open
  • M-s-s to save
  • M-S-s-s to save as

?..

freetonik avatar Jul 17 '20 16:07 freetonik