Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save As Dialog #22

Open
jkhsch opened this issue Jun 8, 2020 · 1 comment
Open

Save As Dialog #22

jkhsch opened this issue Jun 8, 2020 · 1 comment

Comments

@jkhsch
Copy link

jkhsch commented Jun 8, 2020

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)

@freetonik
Copy link
Owner

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

?..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants