GNU bug report logs - #5954
23.1; ps-run-mode should derive from comint-mode

Previous Next

Package: emacs;

Reported by: Markus Triska <markus.triska <at> gmx.at>

Date: Thu, 15 Apr 2010 19:44:01 UTC

Severity: wishlist

Tags: patch

Fixed in version 24.1

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 5954 in the body.
You can then email your comments to 5954 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5954; Package emacs. (Thu, 15 Apr 2010 19:44:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Markus Triska <markus.triska <at> gmx.at>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 15 Apr 2010 19:44:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Markus Triska <markus.triska <at> gmx.at>
To: bug-gnu-emacs <at> gnu.org
Subject: 23.1; ps-run-mode should derive from comint-mode
Date: Thu, 15 Apr 2010 21:36:25 +0200
ps-run-mode should be derived from comint-mode instead of fundamental
mode to get input history etc. The following patch implements this:

2010-04-15  Markus Triska  <markus.triska <at> gmx.at>

	* progmodes/ps-mode.el: Require commint.
	(ps-run-mode-map): Adapt for comint-mode; omit "\r", [return]..
	(ps-mode-other-newline): Simplify.
	(ps-run-mode): Derive from comint-mode instead of
	fundamental-mode, yielding input history etc.
	(ps-run-start, ps-run-quit, ps-run-clear, ps-run-region)
	(ps-run-send-string): Adapt for comint-mode.
	(ps-run-newline): Remove now unneeded function.


diff --git a/ps-mode.el b/ps-mode.el
index 93a5592..e4469b0 100644
--- a/ps-mode.el
+++ b/ps-mode.el
@@ -39,6 +39,7 @@
 (defconst ps-mode-version "1.1h, 16 Jun 2005")
 (defconst ps-mode-maintainer-address "Peter Kleiweg <p.c.j.kleiweg <at> rug.nl>")
 
+(require 'comint)
 (require 'easymenu)
 
 ;; Define core `PostScript' group.
@@ -431,12 +432,11 @@ If nil, use `temporary-file-directory'."
 
 (unless ps-run-mode-map
   (setq ps-run-mode-map (make-sparse-keymap))
+  (set-keymap-parent ps-run-mode-map comint-mode-map)
   (define-key ps-run-mode-map "\C-c\C-q" 'ps-run-quit)
   (define-key ps-run-mode-map "\C-c\C-k" 'ps-run-kill)
   (define-key ps-run-mode-map "\C-c\C-e" 'ps-run-goto-error)
-  (define-key ps-run-mode-map [mouse-2] 'ps-run-mouse-goto-error)
-  (define-key ps-run-mode-map "\r" 'ps-run-newline)
-  (define-key ps-run-mode-map [return] 'ps-run-newline))
+  (define-key ps-run-mode-map [mouse-2] 'ps-run-mouse-goto-error))
 
 
 ;; Syntax table.
@@ -718,12 +718,9 @@ defines the beginning of a group. These tokens are:  {  [  <<"
   (blink-matching-open))
 
 (defun ps-mode-other-newline ()
-  "Perform newline in `*ps run*' buffer."
+  "Perform newline in `*ps-run*' buffer."
   (interactive)
-  (let ((buf (current-buffer)))
-    (set-buffer "*ps run*")
-    (ps-run-newline)
-    (set-buffer buf)))
+  (ps-run-send-string ""))
 
 
 ;; Print PostScript.
@@ -980,7 +977,7 @@ plus the usually uncoded characters inserted on positions 1 through 28."
 
 ;; Interactive PostScript interpreter.
 
-(define-derived-mode ps-run-mode fundamental-mode "Interactive PS"
+(define-derived-mode ps-run-mode comint-mode "Interactive PS"
   "Major mode in interactive PostScript window.
 This mode is invoked from `ps-mode' and should not be called directly.
 
@@ -1014,20 +1011,23 @@ This mode is invoked from `ps-mode' and should not be called directly.
       (setq init-file (ps-run-make-tmp-filename))
       (write-region (concat ps-run-init "\n") 0 init-file)
       (setq init-file (list init-file)))
-    (pop-to-buffer "*ps run*")
+    (pop-to-buffer "*ps-run*")
     (ps-run-mode)
     (when (process-status "ps-run")
       (delete-process "ps-run"))
     (erase-buffer)
     (setq command (append command init-file))
     (insert (mapconcat 'identity command " ") "\n")
-    (apply 'start-process "ps-run" "*ps run*" command)
+    (apply 'make-comint "ps-run" (car command) nil (cdr command))
+    (with-current-buffer "*ps-run*"
+      (use-local-map ps-run-mode-map)
+      (setq comint-prompt-regexp ps-run-prompt))
     (select-window oldwin)))
 
 (defun ps-run-quit ()
   "Quit interactive PostScript."
   (interactive)
-  (ps-run-send-string "quit" t)
+  (ps-run-send-string "quit")
   (ps-run-cleanup))
 
 (defun ps-run-kill ()
@@ -1039,9 +1039,9 @@ This mode is invoked from `ps-mode' and should not be called directly.
 (defun ps-run-clear ()
   "Clear/reset PostScript graphics."
   (interactive)
-  (ps-run-send-string "showpage" t)
+  (ps-run-send-string "showpage")
   (sit-for 1)
-  (ps-run-send-string "" t))
+  (ps-run-send-string ""))
 
 (defun ps-run-buffer ()
   "Send buffer to PostScript interpreter."
@@ -1056,7 +1056,7 @@ This mode is invoked from `ps-mode' and should not be called directly.
   (let ((f (ps-run-make-tmp-filename)))
     (set-marker ps-run-mark begin)
     (write-region begin end f)
-    (ps-run-send-string (format "(%s) run" f) t)))
+    (ps-run-send-string (format "(%s) run" f))))
 
 (defun ps-run-boundingbox ()
   "View BoundingBox."
@@ -1104,17 +1104,15 @@ grestore
 " x1 y1 x2 y1 x2 y2 x1 y2)
      0
      f)
-    (ps-run-send-string (format "(%s) run" f) t)
+    (ps-run-send-string (format "(%s) run" f))
     (set-buffer buf)))
 
-(defun ps-run-send-string (string &optional echo)
+(defun ps-run-send-string (string)
   (let ((oldwin (selected-window)))
-    (pop-to-buffer "*ps run*")
-    (goto-char (point-max))
-    (when echo
-      (insert string "\n"))
-    (set-marker (process-mark (get-process "ps-run")) (point))
-    (process-send-string "ps-run" (concat string "\n"))
+    (pop-to-buffer "*ps-run*")
+    (comint-goto-process-mark)
+    (insert string)
+    (comint-send-input)
     (select-window oldwin)))
 
 (defun ps-run-make-tmp-filename ()
@@ -1140,18 +1138,6 @@ grestore
   (mouse-set-point event)
   (ps-run-goto-error))
 
-(defun ps-run-newline ()
-  "Process newline in PostScript interpreter window."
-  (interactive)
-  (end-of-line)
-  (insert "\n")
-  (forward-line -1)
-  (when (looking-at ps-run-prompt)
-    (goto-char (match-end 0)))
-  (looking-at ".*")
-  (goto-char (1+ (match-end 0)))
-  (ps-run-send-string (buffer-substring (match-beginning 0) (match-end 0))))
-
 (defun ps-run-goto-error ()
   "Jump to buffer position read as integer at point.
 Use line numbers if `ps-run-error-line-numbers' is not nil"


In GNU Emacs 23.1.1 (i386-apple-darwin9.8.0, GTK+ Version 2.14.7)
 of 2009-09-05 on mt-imac.local





Added tag(s) patch. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sun, 18 Apr 2010 18:35:01 GMT) Full text and rfc822 format available.

Severity set to 'wishlist' from 'normal' Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sun, 18 Apr 2010 18:35:01 GMT) Full text and rfc822 format available.

Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5954; Package emacs. (Fri, 23 Jul 2010 22:58:02 GMT) Full text and rfc822 format available.

Message #12 received at 5954 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Markus Triska <markus.triska <at> gmx.at>
Cc: 5954 <at> debbugs.gnu.org
Subject: Re: bug#5954: 23.1; ps-run-mode should derive from comint-mode
Date: Sat, 24 Jul 2010 00:57:19 +0200
> ps-run-mode should be derived from comint-mode instead of fundamental
> mode to get input history etc. The following patch implements this:

Thank you, installed,


        Stefan "prompt is my middle name"




bug marked as fixed in version 24.1, send any further explanations to 5954 <at> debbugs.gnu.org and Markus Triska <markus.triska <at> gmx.at> Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sun, 06 Mar 2011 06:50:04 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 03 Apr 2011 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 14 years and 84 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.