X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/49f70d46ea38ceb7a501594db7f6ea35e19681aa..9f46df23a3d01f82a24f2a3dd8730f0263fa9fde:/lisp/progmodes/ps-mode.el diff --git a/lisp/progmodes/ps-mode.el b/lisp/progmodes/ps-mode.el index b6af168a16..bf52eff8f9 100644 --- a/lisp/progmodes/ps-mode.el +++ b/lisp/progmodes/ps-mode.el @@ -1,12 +1,11 @@ ;;; ps-mode.el --- PostScript mode for GNU Emacs -;; Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 -;; Free Software Foundation, Inc. +;; Copyright (C) 1999, 2001-2012 Free Software Foundation, Inc. ;; Author: Peter Kleiweg ;; Maintainer: Peter Kleiweg ;; Created: 20 Aug 1997 -;; Version: 1.1h, 16 Jun 2005 +;; Version: 1.1h ;; Keywords: PostScript, languages ;; Yoni Rabkin contacted the maintainer of this @@ -39,6 +38,7 @@ (defconst ps-mode-version "1.1h, 16 Jun 2005") (defconst ps-mode-maintainer-address "Peter Kleiweg ") +(require 'comint) (require 'easymenu) ;; Define core `PostScript' group. @@ -60,17 +60,17 @@ ;; User variables. (defcustom ps-mode-auto-indent t - "*Should we use autoindent?" + "Should we use autoindent?" :group 'PostScript-edit :type 'boolean) (defcustom ps-mode-tab 4 - "*Number of spaces to use when indenting." + "Number of spaces to use when indenting." :group 'PostScript-edit :type 'integer) (defcustom ps-mode-paper-size '(595 842) - "*Default paper size. + "Default paper size. When inserting an EPSF template these values are used to set the boundingbox to include the whole page. @@ -117,12 +117,12 @@ When the figure is finished these values should be replaced." (lpr-command (if (memq system-type '(usg-unix-v hpux irix)) "lp" "lpr"))) (lpr-buffer))) - "*Lisp function to print current buffer as PostScript." + "Lisp function to print current buffer as PostScript." :group 'PostScript-edit :type 'function) (defcustom ps-run-prompt "\\(GS\\(<[0-9]+\\)?>\\)+" - "*Regexp to match prompt in interactive PostScript." + "Regexp to match prompt in interactive PostScript." :group 'PostScript-interaction :type 'regexp) @@ -139,7 +139,7 @@ When the figure is finished these values should be replaced." ("^\\(Current file position is\\) \\([0-9]+\\)" (1 font-lock-comment-face nil nil) (2 font-lock-warning-face nil nil)))) - "*Medium level highlighting of messages from the PostScript interpreter. + "Medium level highlighting of messages from the PostScript interpreter. See documentation on font-lock for details." :group 'PostScript-interaction @@ -155,17 +155,17 @@ See documentation on font-lock for details." (boolean :tag "Laxmatch" :value t)))))) (defcustom ps-run-x '("gs" "-r72" "-sPAPERSIZE=a4") - "*Command as list to run PostScript with graphic display." + "Command as list to run PostScript with graphic display." :group 'PostScript-interaction :type '(repeat string)) (defcustom ps-run-dumb '("gs" "-dNODISPLAY") - "*Command as list to run PostScript without graphic display." + "Command as list to run PostScript without graphic display." :group 'PostScript-interaction :type '(repeat string)) (defcustom ps-run-init nil - "*String of commands to send to PostScript to start interactive. + "String of commands to send to PostScript to start interactive. Example: \"executive\" @@ -174,13 +174,13 @@ You won't need to set this option for Ghostscript." :type '(choice (const nil) string)) (defcustom ps-run-error-line-numbers nil - "*What values are used by the PostScript interpreter in error messages?" + "What values are used by the PostScript interpreter in error messages?" :group 'PostScript-interaction :type '(choice (const :tag "line numbers" t) (const :tag "byte counts" nil))) (defcustom ps-run-tmp-dir nil - "*Name of directory to place temporary file. + "Name of directory to place temporary file. If nil, use `temporary-file-directory'." :group 'PostScript-interaction :type '(choice (const nil) directory)) @@ -267,7 +267,7 @@ If nil, use `temporary-file-directory'." . (1 font-lock-function-name-face)) '("/\\w+" . font-lock-variable-name-face) (cons ps-mode-operators 'font-lock-keyword-face))) - "High level highliting for PostScript mode.") + "High level highlighting for PostScript mode.") (defconst ps-mode-font-lock-keywords ps-mode-font-lock-keywords-1 "Default expressions to highlight in PostScript mode.") @@ -431,12 +431,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. @@ -486,7 +485,7 @@ If nil, use `temporary-file-directory'." ;; PostScript mode. ;;;###autoload -(define-derived-mode ps-mode fundamental-mode "PostScript" +(define-derived-mode ps-mode prog-mode "PostScript" "Major mode for editing PostScript with GNU Emacs. Entry to this mode calls `ps-mode-hook'. @@ -542,6 +541,10 @@ Typing \\\\[ps-run-goto-error] when the cursor is at the number (interactive) (message " *** PostScript Mode (ps-mode) Version %s *** " ps-mode-version)) +;; From reporter.el +(defvar reporter-prompt-for-summary-p) +(defvar reporter-dont-compact-list) + (defun ps-mode-submit-bug-report () "Submit via mail a bug report on PostScript mode." (interactive) @@ -621,7 +624,7 @@ Typing \\\\[ps-run-goto-error] when the cursor is at the number (defun ps-mode-target-column () "To what column should text on current line be indented? -Identation is increased if the last token on the current line +Indentation is increased if the last token on the current line defines the beginning of a group. These tokens are: { [ <<" (save-excursion (beginning-of-line) @@ -681,7 +684,7 @@ defines the beginning of a group. These tokens are: { [ <<" (if (or (not ps-mode-auto-indent) (< ps-mode-tab 1) (not (re-search-backward "^[ \t]+\\=" nil t))) - (delete-backward-char 1) + (call-interactively 'delete-backward-char) (setq target (ps-mode-target-column)) (while (> column target) (setq target (+ target ps-mode-tab))) @@ -710,7 +713,7 @@ defines the beginning of a group. These tokens are: { [ <<" (ps-mode-r-balance ">>")) (defun ps-mode-r-balance (right) - "Adjust indentification if point after RIGHT." + "Adjust indenting if point after RIGHT." (if ps-mode-auto-indent (save-excursion (when (re-search-backward (concat "^[ \t]*" (regexp-quote right) "\\=") nil t) @@ -718,12 +721,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,11 +980,9 @@ 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. - -\\{ps-run-mode-map}" +This mode is invoked from `ps-mode' and should not be called directly." (set (make-local-variable 'font-lock-defaults) '((ps-run-font-lock-keywords ps-run-font-lock-keywords-1 @@ -994,7 +992,7 @@ This mode is invoked from `ps-mode' and should not be called directly. (defun ps-run-running () "Error if not in `ps-mode' or not running PostScript." - (unless (equal major-mode 'ps-mode) + (unless (derived-mode-p 'ps-mode) (error "This function can only be called from PostScript mode")) (unless (equal (process-status "ps-run") 'run) (error "No PostScript process running"))) @@ -1014,20 +1012,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 +1040,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 +1057,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 +1105,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 +1139,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" @@ -1183,5 +1170,4 @@ Use line numbers if `ps-run-error-line-numbers' is not nil" (provide 'ps-mode) -;; arch-tag: dce13d2d-69fb-4ec4-9d5d-6dd29c3f0e6e ;;; ps-mode.el ends here