-
Notifications
You must be signed in to change notification settings - Fork 0
/
longmacs-1.4.el
62 lines (50 loc) · 2 KB
/
longmacs-1.4.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
;;; longmacs.el --- Make it a little harder to deny emacs is an OS
;; Copyright 2017 by Dave Pearson <davep@davep.org>
;; Author: Dave Pearson <davep@davep.org>
;; Version: 1.4
;; Keywords: convenience, server
;; URL: https://github.com/davep/longmacs.el
;; Package-Requires: ((bind-key "1.0"))
;; longmacs.el is free software distributed under the terms of the GNU
;; General Public Licence, version 2 or (at your option) any later version.
;; For details see the file COPYING.
;;; Commentary:
;;
;; longmacs.el is designed to help me treat Emacs as something that should
;; be kept running for a long time. There's no need to start and stop an
;; editor like Emacs and this little package contains the bits I use to help
;; me keep bad habits under control.
;;
;; On my iMac and Macbook I tend to start an Emacs sesssion, run
;; `longmacs', turn it into a full-screen application, and then do
;; all my editing in there.
;;
;; See also uptimes.el for another tool to help encourage good Emacs use.
;;; Code:
(require 'bind-key)
(defvar longmacs-exit-keys nil
"Holds on to the keys that would have been pressed to invoke
`save-buffers-kill-terminal'. Populated by `longmacs' when first
run.")
;;;###autoload
(defun longmacs-no-exit ()
"Do nothing other than say we're doing nothing."
(interactive)
(if longmacs-exit-keys
(message "%s is disabled." longmacs-exit-keys)
(message "longmacs hasn't been called.")))
;;;###autoload
(defun longmacs ()
"Turn this emacs sesssion into a long term emacs.
This involves disabling the keyboard binding for
`save-buffers-kill-terminal' (which is normally C-x C-c) and also
calling `server-start'.
If you do need to exit emacs, simply \\[kill-emacs] instead."
(interactive)
(server-start)
(unless longmacs-exit-keys
(setq longmacs-exit-keys (substitute-command-keys "\\[save-buffers-kill-terminal]"))
(bind-key longmacs-exit-keys #'longmacs-no-exit))
(message "%s now disabled and server started." longmacs-exit-keys))
(provide 'longmacs)
;;; longmacs.el ends here