aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2019-06-13 17:40:32 -0400
committerStefan Monnier2019-06-13 17:40:32 -0400
commitcf5aa2f39a3ea2b3ba49063c0d46c27878292a46 (patch)
treea895fe1df5c557f35ce16350c25d0f544b1e586e
parentd64d36de8eddb7752f94b809c04822f442f44110 (diff)
downloademacs-cf5aa2f39a3ea2b3ba49063c0d46c27878292a46.tar.gz
emacs-cf5aa2f39a3ea2b3ba49063c0d46c27878292a46.zip
* lisp/progmodes/ps-mode.el (ps-mode-octal-region): Simplify.
-rw-r--r--lisp/progmodes/ps-mode.el37
1 files changed, 15 insertions, 22 deletions
diff --git a/lisp/progmodes/ps-mode.el b/lisp/progmodes/ps-mode.el
index 989a9941b44..b589cab9c25 100644
--- a/lisp/progmodes/ps-mode.el
+++ b/lisp/progmodes/ps-mode.el
@@ -724,25 +724,18 @@ Only one `%' is removed, and it has to be in the first column."
724 724
725(defun ps-mode-octal-region (begin end) 725(defun ps-mode-octal-region (begin end)
726 "Change 8-bit characters to octal codes in region." 726 "Change 8-bit characters to octal codes in region."
727 (interactive "r") 727 (interactive "*r")
728 (if buffer-read-only 728 (save-excursion
729 (progn 729 (let ((endm (copy-marker end))
730 (ding) 730 (i 0))
731 (message "Buffer is read only")) 731 (goto-char begin)
732 (save-excursion 732 (while (re-search-forward "[\200-\377]" (marker-position endm) t)
733 (let (endm i) 733 (setq i (1+ i))
734 (setq endm (make-marker)) 734 (replace-match (format "\\%03o"
735 (set-marker endm end) 735 (multibyte-char-to-unibyte (char-before)))
736 (goto-char begin) 736 t t))
737 (setq i 0) 737 (message "%d change%s made" i (if (= i 1) "" "s"))
738 (while (re-search-forward "[\200-\377]" (marker-position endm) t) 738 (set-marker endm nil))))
739 (setq i (1+ i))
740 (replace-match (format "\\%03o"
741 (multibyte-char-to-unibyte
742 (char-after (1- (point)))))
743 t t))
744 (message "%d change%s made" i (if (= i 1) "" "s"))
745 (set-marker endm nil)))))
746 739
747 740
748;; Cookbook. 741;; Cookbook.
@@ -952,11 +945,11 @@ This mode is invoked from `ps-mode' and should not be called directly."
952 (delete-process "ps-run")) 945 (delete-process "ps-run"))
953 (erase-buffer) 946 (erase-buffer)
954 (setq command (append command init-file)) 947 (setq command (append command init-file))
955 (insert (mapconcat 'identity command " ") "\n") 948 (insert (mapconcat #'identity command " ") "\n")
956 (apply 'make-comint "ps-run" (car command) nil (cdr command)) 949 (apply #'make-comint "ps-run" (car command) nil (cdr command))
957 (with-current-buffer "*ps-run*" 950 (with-current-buffer "*ps-run*"
958 (use-local-map ps-run-mode-map) 951 (use-local-map ps-run-mode-map)
959 (setq comint-prompt-regexp ps-run-prompt)) 952 (setq-local comint-prompt-regexp ps-run-prompt))
960 (select-window oldwin))) 953 (select-window oldwin)))
961 954
962(defun ps-run-quit () 955(defun ps-run-quit ()