yatex

changeset 19:6b0fab5e8eea

*** empty log message ***
author yuuji
date Thu, 07 Jul 1994 16:37:05 +0000
parents adc2f1472409
children b6127058e365
files comment.el
diffstat 1 files changed, 89 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/comment.el	Thu Jul 07 16:37:05 1994 +0000
     1.3 @@ -0,0 +1,89 @@
     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 +
    1.10 +(provide 'comment)
    1.11 +
    1.12 +(defvar current-comment-prefix "> "
    1.13 +  "default prefix string")
    1.14 +
    1.15 +(defun cite-region nil
    1.16 +  (save-excursion
    1.17 +    (if (< (point) (mark)) (exchange-point-and-mark))
    1.18 +    (if (bolp)
    1.19 +	(forward-line -1))
    1.20 +    (if (string= string "") (setq string current-comment-prefix)
    1.21 +      (setq current-comment-prefix string))
    1.22 +    (save-restriction 
    1.23 +      (narrow-to-region (point) (mark))
    1.24 +      (goto-char (point-min))
    1.25 +      (while (re-search-forward "^" nil t)
    1.26 +	(message "%s" string)
    1.27 +	(replace-match string))
    1.28 +      ))
    1.29 +)
    1.30 +
    1.31 +(defun comment-region (string &optional once)
    1.32 +  "Inserts STRING at the beginning of every line in the region.
    1.33 +Called interactively, STRING defaults to comment-start (or '> ' if
    1.34 +none is defined) unless a prefix argument is given, in which case it
    1.35 +prompts for a string.  Optional second argument ONCE is only for
    1.36 +compatibility for uncomment-region.  It has no means now."
    1.37 +  (interactive
    1.38 +   (list (if current-prefix-arg
    1.39 +	     (read-string 
    1.40 +	      (concat "String to insert"
    1.41 +		      (format "(default \"%s\")" current-comment-prefix
    1.42 +			      " ")
    1.43 +		      ": "))
    1.44 +	   current-comment-prefix
    1.45 +	   )))
    1.46 +  (if (not (stringp string)) (setq string current-comment-prefix))
    1.47 +  (cite-region)
    1.48 +)
    1.49 +
    1.50 +
    1.51 +(defun uncomment-region (string &optional once)
    1.52 +  "Deletes STRING from the beginning of every line in the region.
    1.53 +Called interactively, STRING defaults to comment-start (or '> ' if
    1.54 +none is defined) unless a prefix argument is given, in which case it
    1.55 +prompts for a string.  Optional second argument ONCE restricts
    1.56 +deletion to first occurance of STRING on each line."
    1.57 +  (interactive
    1.58 +   (list (if current-prefix-arg
    1.59 +	     (read-string 
    1.60 +	      (concat "String to delete"
    1.61 +		      (format "(default \"%s\")" current-comment-prefix
    1.62 +			      " ")
    1.63 +		      ": "))
    1.64 +	   current-comment-prefix
    1.65 +	   )))
    1.66 +  (if (not (stringp string)) (setq string current-comment-prefix))
    1.67 +  (save-excursion
    1.68 +    (if (< (point) (mark)) (exchange-point-and-mark))
    1.69 +;    (if (bolp)
    1.70 +;         (forward-line -1))
    1.71 +    (save-restriction 
    1.72 +      (narrow-to-region (point) (mark))
    1.73 +      (goto-char (point-min))
    1.74 +      (while (re-search-forward (concat "^" string) nil t)
    1.75 +	(replace-match "")
    1.76 +	(if once (end-of-line)))
    1.77 +      ))
    1.78 +)
    1.79 +
    1.80 +(defun cite-file (filename)
    1.81 +  "insert the file with citation string."
    1.82 +  (interactive "FCite-file: ")
    1.83 +  (let*
    1.84 +      ((string
    1.85 +	(read-string
    1.86 +	 (format "Citation string (default \"%s\"): " current-comment-prefix)
    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 +)