Commit 7cf19953 authored by David Byers's avatar David Byers
Browse files

kom-next-kom och kom-prev-kom är nu både LysKOM- och Emacs-kommandon.

Nytt makro def-kom-emacs-command för att göra sådana konstigheter
enkla att utföra.
parent c1563e7e
Sun Sep 21 10:25:51 1997 David Byers <davby@ida.liu.se>
* command.el (def-kom-emacs-command): Nytt makro.
(def-kom-command): Skrev om med backquote.
* lyskom-rest.el (silent-read): Stt enable-multibyte-characters
till nil.
......
......@@ -58,18 +58,70 @@
;;; ...)
(defmacro def-kom-command (cmd args doc interactive-decl &rest forms)
(list 'defun cmd args doc interactive-decl
(list 'lyskom-start-of-command (list 'quote cmd))
(list 'unwind-protect
(list 'condition-case nil
(cons 'progn
forms)
(list 'quit
(list 'ding)
(list 'lyskom-insert-before-prompt
(list 'lyskom-get-string
(list 'quote 'interrupted)))))
(list 'lyskom-end-of-command))))
(`
(defun (, cmd) (, args)
(, doc)
(, interactive-decl)
(lyskom-start-of-command (quote (, cmd)))
(unwind-protect
(condition-case nil
(progn (,@ forms))
(quit (ding)
(lyskom-insert-before-prompt
(lyskom-get-string 'interrupted))))
(lyskom-end-of-command)))))
;;
;; def-kom-emacs-command works like def-kom-command, but the template
;; is different. Commands defined this way will run as regular Emacs
;; commands when invoked outside of a LysKOM buffer.
;;
;; The variable <cmd>-running-as-kom-command is non-nil when running
;; as a LysKOM command and nil otherwise.
;;
;; Note: this function catches *all* errors in lyskom-start-of-command
;; which may not be what you want, so be careful.
;;
;;
;; (defun kom-cmd (args)
;; "Documentation"
;; (interactive "...")
;; (let ((kom-cmd-running-as-kom-command nil))
;; (condition-case nil
;; (progn (lyskom-start-of-command 'kom-cmd)
;; (setq kom-cmd-running-as-kom-command t))
;; (error nil))
;; (unwind-protect
;; (condition-case nil
;; (progn ...)
;; (quit (ding)
;; (lyskom-insert-before-prompt
;; (lyskom-get-string 'interrupted))))
;; (and kom-cmd-running-as-kom-command (lyskom-end-of-command)))))
;;
(defmacro def-kom-emacs-command (cmd args doc interactive-decl &rest forms)
(let ((rsym (intern (concat (format "%S-running-as-kom-command"
cmd)))))
(`
(defun (, cmd) (, args)
(, doc)
(, interactive-decl)
(let (((, rsym) nil))
(condition-case nil
(progn (lyskom-start-of-command (quote (, cmd)))
(setq (, rsym) t))
(error nil))
(unwind-protect
(condition-case nil
(progn (,@ forms))
(quit (ding)
(lyskom-insert-before-prompt
(lyskom-get-string 'interrupted))))
(and (, rsym) (lyskom-end-of-command))))))))
(put 'def-kom-command 'edebug-form-spec
......@@ -78,6 +130,12 @@
("interactive" interactive)
def-body))
(put 'def-kom-emacs-command 'edebug-form-spec
'(&define name lambda-list
[&optional stringp] ; Match the doc string, if present.
("interactive" interactive)
def-body))
;;;; ================================================================
......
......@@ -1495,7 +1495,7 @@ membership info."
(def-kom-command kom-next-kom ()
(def-kom-emacs-command kom-next-kom ()
"Pop up the next lyskom-session."
(interactive)
(if (lyskom-buffer-p (current-buffer))
......@@ -1531,7 +1531,7 @@ membership info."
(error "No active LysKOM buffers")))
(def-kom-command kom-previous-kom ()
(def-kom-emacs-command kom-previous-kom ()
"Pop up the previous lyskom-session."
(interactive)
(if (lyskom-buffer-p (current-buffer))
......
......@@ -518,7 +518,8 @@ so it's not as clean as it ought to be."
(save-excursion
(let ((full-message
(cond ((and lyskom-allow-missing-subject
(null subject)
(or (null subject)
(string= subject ""))
(not (string-match ".*\n" message)))
message)
(t (concat (or subject "") "\n" message)))))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment