yatex
changeset 50:b1e036697b20
Change for Emacs-19
author | yuuji |
---|---|
date | Fri, 25 Nov 1994 08:26:13 +0000 |
parents | eb0512bfcb7f |
children | b0371b6ed799 |
files | comment.el |
diffstat | 1 files changed, 20 insertions(+), 23 deletions(-) [+] |
line diff
1.1 --- a/comment.el Fri Nov 25 08:26:13 1994 +0000 1.2 +++ b/comment.el Fri Nov 25 08:26:13 1994 +0000 1.3 @@ -1,32 +1,35 @@ 1.4 ;;; -*- Emacs-Lisp -*- 1.5 ;;; comment/uncomment region for emacs. 1.6 -;;; comment.el rev.0.0 1.7 -;;; (c ) 1992 by Hirose Yuuji.(yuuji@ae.keio.ac.jp) 1.8 -;;; Last modified Sat Jan 29 16:55:22 1994 on gloria 1.9 +;;; comment.el rev.0.1 1.10 +;;; (c) 1992 by Hirose Yuuji.(yuuji@ae.keio.ac.jp) 1.11 +;;; Last modified Sat Nov 19 23:58:40 1994 on figaro 1.12 + 1.13 +;;; Rename `comment-region' to `comment-out-region' for standard 1.14 +;;; Emacs-19 function. 1.15 1.16 (provide 'comment) 1.17 1.18 -(defvar current-comment-prefix "> " 1.19 - "default prefix string") 1.20 +(defvar current-comment-prefix "> " "*Default prefix string") 1.21 1.22 -(defun cite-region nil 1.23 +(defun cite-region (beg end) 1.24 (save-excursion 1.25 - (if (< (point) (mark)) (exchange-point-and-mark)) 1.26 + (goto-char (max beg end)) 1.27 (if (bolp) 1.28 (forward-line -1)) 1.29 (if (string= string "") (setq string current-comment-prefix) 1.30 (setq current-comment-prefix string)) 1.31 (save-restriction 1.32 - (narrow-to-region (point) (mark)) 1.33 + (narrow-to-region (min beg end) (point)) 1.34 (goto-char (point-min)) 1.35 + (message "%s" string) 1.36 (while (re-search-forward "^" nil t) 1.37 - (message "%s" string) 1.38 (replace-match string)) 1.39 )) 1.40 ) 1.41 1.42 -(defun comment-region (string &optional once) 1.43 - "Inserts STRING at the beginning of every line in the region. 1.44 +(defun comment-out-region (string &optional beg end once) 1.45 + "Inserts STRING at the beginning of every line in the region specified 1.46 +BEG and END. 1.47 Called interactively, STRING defaults to comment-start (or '> ' if 1.48 none is defined) unless a prefix argument is given, in which case it 1.49 prompts for a string. Optional second argument ONCE is only for 1.50 @@ -38,14 +41,13 @@ 1.51 (format "(default \"%s\")" current-comment-prefix 1.52 " ") 1.53 ": ")) 1.54 - current-comment-prefix 1.55 - ))) 1.56 + current-comment-prefix))) 1.57 (if (not (stringp string)) (setq string current-comment-prefix)) 1.58 - (cite-region) 1.59 + (cite-region (or beg (region-beginning)) (or end (region-end))) 1.60 ) 1.61 1.62 1.63 -(defun uncomment-region (string &optional once) 1.64 +(defun uncomment-region (string &optional beg end once) 1.65 "Deletes STRING from the beginning of every line in the region. 1.66 Called interactively, STRING defaults to comment-start (or '> ' if 1.67 none is defined) unless a prefix argument is given, in which case it 1.68 @@ -58,15 +60,11 @@ 1.69 (format "(default \"%s\")" current-comment-prefix 1.70 " ") 1.71 ": ")) 1.72 - current-comment-prefix 1.73 - ))) 1.74 + current-comment-prefix))) 1.75 (if (not (stringp string)) (setq string current-comment-prefix)) 1.76 (save-excursion 1.77 - (if (< (point) (mark)) (exchange-point-and-mark)) 1.78 -; (if (bolp) 1.79 -; (forward-line -1)) 1.80 (save-restriction 1.81 - (narrow-to-region (point) (mark)) 1.82 + (narrow-to-region (or beg (region-beginning)) (or end (region-end))) 1.83 (goto-char (point-min)) 1.84 (while (re-search-forward (concat "^" string) nil t) 1.85 (replace-match "") 1.86 @@ -84,6 +82,5 @@ 1.87 )) 1.88 (ins-tail (car (cdr (insert-file-contents filename))))) 1.89 (save-excursion 1.90 - (push-mark (+ (point) ins-tail)) 1.91 - (cite-region))) 1.92 + (cite-region (point) (+ (point) ins-tail)))) 1.93 )