Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. (defvar-local is-new-file-buffer nil)
  2.  
  3. (defun save-new-file-before-kill ()
  4. (when (and (not (buffer-file-name))
  5. is-new-file-buffer
  6. (yes-or-no-p
  7. "New file has not been saved. Would you like to save before closing?"))
  8. (call-interactively 'save-buffer)))
  9.  
  10. (add-hook 'kill-buffer-hook 'save-new-file-before-kill)
  11.  
  12. (defun new-file (dir)
  13. (interactive "DCreate New File In: ")
  14. (let ((buffer (generate-new-buffer "<Unsaved File>")))
  15. (switch-to-buffer buffer)
  16. (setq-local default-directory dir)
  17. (setq-local is-new-file-buffer t)))
  18.  
  19. (globoal-set-key [(f12)] 'new-file)
  20.  
  21. Warning (initialization): An error occurred while loading `/home/christoph/.emacs':
  22.  
  23. Symbol's function definition is void: globoal-set-key
  24.  
  25. To ensure normal operation, you should investigate and remove the
  26. cause of the error in your initialization file. Start Emacs with
  27. the `--debug-init' option to view a complete error backtrace.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement