Commit cf5aa2f3 authored by Stefan Monnier's avatar Stefan Monnier

* lisp/progmodes/ps-mode.el (ps-mode-octal-region): Simplify.

parent d64d36de
Pipeline #2043 failed with stage
in 57 minutes and 58 seconds
...@@ -724,25 +724,18 @@ Only one `%' is removed, and it has to be in the first column." ...@@ -724,25 +724,18 @@ Only one `%' is removed, and it has to be in the first column."
(defun ps-mode-octal-region (begin end) (defun ps-mode-octal-region (begin end)
"Change 8-bit characters to octal codes in region." "Change 8-bit characters to octal codes in region."
(interactive "r") (interactive "*r")
(if buffer-read-only (save-excursion
(progn (let ((endm (copy-marker end))
(ding) (i 0))
(message "Buffer is read only")) (goto-char begin)
(save-excursion (while (re-search-forward "[\200-\377]" (marker-position endm) t)
(let (endm i) (setq i (1+ i))
(setq endm (make-marker)) (replace-match (format "\\%03o"
(set-marker endm end) (multibyte-char-to-unibyte (char-before)))
(goto-char begin) t t))
(setq i 0) (message "%d change%s made" i (if (= i 1) "" "s"))
(while (re-search-forward "[\200-\377]" (marker-position endm) t) (set-marker endm nil))))
(setq i (1+ i))
(replace-match (format "\\%03o"
(multibyte-char-to-unibyte
(char-after (1- (point)))))
t t))
(message "%d change%s made" i (if (= i 1) "" "s"))
(set-marker endm nil)))))
;; Cookbook. ;; Cookbook.
...@@ -952,11 +945,11 @@ This mode is invoked from `ps-mode' and should not be called directly." ...@@ -952,11 +945,11 @@ This mode is invoked from `ps-mode' and should not be called directly."
(delete-process "ps-run")) (delete-process "ps-run"))
(erase-buffer) (erase-buffer)
(setq command (append command init-file)) (setq command (append command init-file))
(insert (mapconcat 'identity command " ") "\n") (insert (mapconcat #'identity command " ") "\n")
(apply 'make-comint "ps-run" (car command) nil (cdr command)) (apply #'make-comint "ps-run" (car command) nil (cdr command))
(with-current-buffer "*ps-run*" (with-current-buffer "*ps-run*"
(use-local-map ps-run-mode-map) (use-local-map ps-run-mode-map)
(setq comint-prompt-regexp ps-run-prompt)) (setq-local comint-prompt-regexp ps-run-prompt))
(select-window oldwin))) (select-window oldwin)))
(defun ps-run-quit () (defun ps-run-quit ()
......
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