view comment.el @ 23:b00c74813e56

Change the YaTeX-math-mode's prefix from `,' to `;'. Add YaTeX-apropos, YaTeX-what-column, YaTeX-beginning-of-environment, YaTeX-end-of-environment. Add variables YaTeX-default-pop-window-height, YaTeX-close-paren-always, YaTeX-no-begend-shortcut, YaTeX-auto-math-mode. Remove Greek letters from maketitle-type. Make YaTeX-inner-environment two times faster and more reliable. C-u for [prefix] k kills contents too. Fix the detection of the range of section-type commands when nested. Add \end{ completion. Add YaTeX-generate-simple. Refine documents(using Texinfo). %#REQUIRE for sub-preambles.
author yuuji
date Thu, 07 Jul 1994 16:37:05 +0000
parents 6b0fab5e8eea
children b1e036697b20
line wrap: on
line source

;;; -*- Emacs-Lisp -*-
;;; comment/uncomment region for emacs.
;;; comment.el rev.0.0
;;; (c ) 1992 by Hirose Yuuji.(yuuji@ae.keio.ac.jp)
;;; Last modified Sat Jan 29 16:55:22 1994 on gloria

(provide 'comment)

(defvar current-comment-prefix "> "
  "default prefix string")

(defun cite-region nil
  (save-excursion
    (if (< (point) (mark)) (exchange-point-and-mark))
    (if (bolp)
	(forward-line -1))
    (if (string= string "") (setq string current-comment-prefix)
      (setq current-comment-prefix string))
    (save-restriction 
      (narrow-to-region (point) (mark))
      (goto-char (point-min))
      (while (re-search-forward "^" nil t)
	(message "%s" string)
	(replace-match string))
      ))
)

(defun comment-region (string &optional once)
  "Inserts STRING at the beginning of every line in the region.
Called interactively, STRING defaults to comment-start (or '> ' if
none is defined) unless a prefix argument is given, in which case it
prompts for a string.  Optional second argument ONCE is only for
compatibility for uncomment-region.  It has no means now."
  (interactive
   (list (if current-prefix-arg
	     (read-string 
	      (concat "String to insert"
		      (format "(default \"%s\")" current-comment-prefix
			      " ")
		      ": "))
	   current-comment-prefix
	   )))
  (if (not (stringp string)) (setq string current-comment-prefix))
  (cite-region)
)


(defun uncomment-region (string &optional once)
  "Deletes STRING from the beginning of every line in the region.
Called interactively, STRING defaults to comment-start (or '> ' if
none is defined) unless a prefix argument is given, in which case it
prompts for a string.  Optional second argument ONCE restricts
deletion to first occurance of STRING on each line."
  (interactive
   (list (if current-prefix-arg
	     (read-string 
	      (concat "String to delete"
		      (format "(default \"%s\")" current-comment-prefix
			      " ")
		      ": "))
	   current-comment-prefix
	   )))
  (if (not (stringp string)) (setq string current-comment-prefix))
  (save-excursion
    (if (< (point) (mark)) (exchange-point-and-mark))
;    (if (bolp)
;         (forward-line -1))
    (save-restriction 
      (narrow-to-region (point) (mark))
      (goto-char (point-min))
      (while (re-search-forward (concat "^" string) nil t)
	(replace-match "")
	(if once (end-of-line)))
      ))
)

(defun cite-file (filename)
  "insert the file with citation string."
  (interactive "FCite-file: ")
  (let*
      ((string
	(read-string
	 (format "Citation string (default \"%s\"): " current-comment-prefix)
	 ))
       (ins-tail (car (cdr (insert-file-contents filename)))))
    (save-excursion
      (push-mark (+ (point) ins-tail))
      (cite-region)))
)

yatex.org