Emacs: Override desktop lock when no Emacsen is owning it

master
Pierre Neidhardt 2015-04-25 13:47:00 +02:00
parent 3b0e8cafc1
commit 5c4e3325b4
2 changed files with 15 additions and 0 deletions

View File

@ -127,6 +127,16 @@ there's a region, all lines that region covers will be duplicated."
(goto-char (+ origin (* (length region) arg) arg)))))
(define-key my-keys-minor-mode-map (kbd "C-x M-d") 'duplicate)
(defun emacs-process-p (pid)
"If pid is the process ID of an emacs process, return t, else nil.
Also returns nil if pid is nil."
(when pid
(let ((attributes (process-attributes pid)) (cmd))
(dolist (attr attributes)
(if (string= "comm" (car attr))
(setq cmd (cdr attr))))
(if (and cmd (or (string= "emacs" cmd) (string= "emacs.exe" cmd))) t))))
(defun escape-region (&optional regex to-string)
"Escape double-quotes and backslashes.
You can control the regex replacement with the two optional

View File

@ -279,6 +279,11 @@
;; Common LISP
(setq inferior-lisp-program "clisp")
(defadvice desktop-owner (after pry-from-cold-dead-hands activate)
"Don't allow dead emacsen to own the desktop file."
(when (not (emacs-process-p ad-return-value))
(setq ad-return-value nil)))
;; Let Emacs auto-load/save sessions.
(when (getenv "EMACS_SERVER")
(desktop-save-mode 1)