yatex

annotate comment.el @ 43:ef686a35472d

Change the default section-type command to footnotetext after maketitle-type completion: footnotemark.
author yuuji
date Sun, 24 Jul 1994 15:07:23 +0000
parents
children b1e036697b20
rev   line source
yuuji@19 1 ;;; -*- Emacs-Lisp -*-
yuuji@19 2 ;;; comment/uncomment region for emacs.
yuuji@19 3 ;;; comment.el rev.0.0
yuuji@19 4 ;;; (c ) 1992 by Hirose Yuuji.(yuuji@ae.keio.ac.jp)
yuuji@19 5 ;;; Last modified Sat Jan 29 16:55:22 1994 on gloria
yuuji@19 6
yuuji@19 7 (provide 'comment)
yuuji@19 8
yuuji@19 9 (defvar current-comment-prefix "> "
yuuji@19 10 "default prefix string")
yuuji@19 11
yuuji@19 12 (defun cite-region nil
yuuji@19 13 (save-excursion
yuuji@19 14 (if (< (point) (mark)) (exchange-point-and-mark))
yuuji@19 15 (if (bolp)
yuuji@19 16 (forward-line -1))
yuuji@19 17 (if (string= string "") (setq string current-comment-prefix)
yuuji@19 18 (setq current-comment-prefix string))
yuuji@19 19 (save-restriction
yuuji@19 20 (narrow-to-region (point) (mark))
yuuji@19 21 (goto-char (point-min))
yuuji@19 22 (while (re-search-forward "^" nil t)
yuuji@19 23 (message "%s" string)
yuuji@19 24 (replace-match string))
yuuji@19 25 ))
yuuji@19 26 )
yuuji@19 27
yuuji@19 28 (defun comment-region (string &optional once)
yuuji@19 29 "Inserts STRING at the beginning of every line in the region.
yuuji@19 30 Called interactively, STRING defaults to comment-start (or '> ' if
yuuji@19 31 none is defined) unless a prefix argument is given, in which case it
yuuji@19 32 prompts for a string. Optional second argument ONCE is only for
yuuji@19 33 compatibility for uncomment-region. It has no means now."
yuuji@19 34 (interactive
yuuji@19 35 (list (if current-prefix-arg
yuuji@19 36 (read-string
yuuji@19 37 (concat "String to insert"
yuuji@19 38 (format "(default \"%s\")" current-comment-prefix
yuuji@19 39 " ")
yuuji@19 40 ": "))
yuuji@19 41 current-comment-prefix
yuuji@19 42 )))
yuuji@19 43 (if (not (stringp string)) (setq string current-comment-prefix))
yuuji@19 44 (cite-region)
yuuji@19 45 )
yuuji@19 46
yuuji@19 47
yuuji@19 48 (defun uncomment-region (string &optional once)
yuuji@19 49 "Deletes STRING from the beginning of every line in the region.
yuuji@19 50 Called interactively, STRING defaults to comment-start (or '> ' if
yuuji@19 51 none is defined) unless a prefix argument is given, in which case it
yuuji@19 52 prompts for a string. Optional second argument ONCE restricts
yuuji@19 53 deletion to first occurance of STRING on each line."
yuuji@19 54 (interactive
yuuji@19 55 (list (if current-prefix-arg
yuuji@19 56 (read-string
yuuji@19 57 (concat "String to delete"
yuuji@19 58 (format "(default \"%s\")" current-comment-prefix
yuuji@19 59 " ")
yuuji@19 60 ": "))
yuuji@19 61 current-comment-prefix
yuuji@19 62 )))
yuuji@19 63 (if (not (stringp string)) (setq string current-comment-prefix))
yuuji@19 64 (save-excursion
yuuji@19 65 (if (< (point) (mark)) (exchange-point-and-mark))
yuuji@19 66 ; (if (bolp)
yuuji@19 67 ; (forward-line -1))
yuuji@19 68 (save-restriction
yuuji@19 69 (narrow-to-region (point) (mark))
yuuji@19 70 (goto-char (point-min))
yuuji@19 71 (while (re-search-forward (concat "^" string) nil t)
yuuji@19 72 (replace-match "")
yuuji@19 73 (if once (end-of-line)))
yuuji@19 74 ))
yuuji@19 75 )
yuuji@19 76
yuuji@19 77 (defun cite-file (filename)
yuuji@19 78 "insert the file with citation string."
yuuji@19 79 (interactive "FCite-file: ")
yuuji@19 80 (let*
yuuji@19 81 ((string
yuuji@19 82 (read-string
yuuji@19 83 (format "Citation string (default \"%s\"): " current-comment-prefix)
yuuji@19 84 ))
yuuji@19 85 (ins-tail (car (cdr (insert-file-contents filename)))))
yuuji@19 86 (save-excursion
yuuji@19 87 (push-mark (+ (point) ins-tail))
yuuji@19 88 (cite-region)))
yuuji@19 89 )