# HG changeset patch # User HIROSE Yuuji # Date 1505045321 -32373 # Node ID 9132c20372ecafd836180826a2d9ce19b4ba5e94 # Parent 723f136edde54e83d69c6e2284b4b5652d3e63b0 Remove comment.el and incorporate it into yatexlib.el diff -r 723f136edde5 -r 9132c20372ec comment.el --- a/comment.el Sun Sep 10 17:03:34 2017 +0859 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,86 +0,0 @@ -;;; -*- Emacs-Lisp -*- -;;; comment/uncomment region for emacs. -;;; comment.el rev.0.1 -;;; (c) 1992, 2002 by HIROSE Yuuji.(yuuji@yatex.org) -;;; Last modified Mon Nov 25 18:33:23 2002 on firestorm - -;;; Rename `comment-region' to `comment-out-region' for standard -;;; Emacs-19 function. - -(provide 'comment) - -(defvar current-comment-prefix "> " "*Default prefix string") - -(defun cite-region (beg end) - (save-excursion - (goto-char (max beg end)) - (if (bolp) - (forward-line -1)) - (if (string= string "") (setq string current-comment-prefix) - (setq current-comment-prefix string)) - (save-restriction - (narrow-to-region (min beg end) (point)) - (goto-char (point-min)) - (message "%s" string) - (while (re-search-forward "^" nil t) - (replace-match string)) - )) -) - -(defun comment-out-region (string &optional beg end once) - "Inserts STRING at the beginning of every line in the region specified -BEG and END. -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 (or beg (region-beginning)) (or end (region-end))) -) - - -(defun uncomment-out-region (string &optional beg end 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 - (save-restriction - (narrow-to-region (or beg (region-beginning)) (or end (region-end))) - (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 - (cite-region (point) (+ (point) ins-tail)))) -) diff -r 723f136edde5 -r 9132c20372ec yatex.el --- a/yatex.el Sun Sep 10 17:03:34 2017 +0859 +++ b/yatex.el Sun Sep 10 21:08:14 2017 +0859 @@ -1,14 +1,13 @@ ;;; yatex.el --- Yet Another tex-mode for emacs //–ì’¹// -*- coding: sjis -*- ;;; (c)1991-2017 by HIROSE Yuuji.[yuuji@yatex.org] -;;; Last modified Sun Sep 10 09:51:57 2017 on firestorm +;;; Last modified Sun Sep 10 20:30:31 2017 on firestorm ;;; $Id$ ;;; The latest version of this software is always available at; ;;; http://www.yatex.org/ ;;; Code: -(require 'comment) (require 'yatexlib) -(defconst YaTeX-revision-number "1.79.4" +(defconst YaTeX-revision-number "1.80" "Revision number of running yatex.el") ;---------- Local variables ---------- @@ -2256,34 +2255,40 @@ it comments out whole environment" (interactive "P") (if (not (YaTeX-on-begin-end-p)) - (comment-out-region + (YaTeX-comment-region-sub (if alt-prefix (read-string-with-history "Insert prefix: ") YaTeX-comment-prefix)) - (YaTeX-comment-uncomment-env 'comment-out-region))) + (YaTeX-comment-uncomment-env 'YaTeX-comment-region-sub))) (defun YaTeX-uncomment-region (alt-prefix) "Uncomment out region by '%'." (interactive "P") (if (not (YaTeX-on-begin-end-p)) - (uncomment-out-region + (YaTeX-uncomment-region-sub (if alt-prefix (read-string-with-history "Remove prefix: ") YaTeX-comment-prefix) (region-beginning) (region-end) YaTeX-uncomment-once) - (YaTeX-comment-uncomment-env 'uncomment-out-region))) + (YaTeX-comment-uncomment-env 'YaTeX-uncomment-region-sub))) (defun YaTeX-comment-uncomment-env (func) "Comment or uncomment out one LaTeX environment switching function by FUNC." - (let (beg (p (point))) + (let (beg beg2 (p (point))) (save-excursion - (beginning-of-line) - (setq beg (point)) - (YaTeX-goto-corresponding-environment) - (beginning-of-line) - (if (> p (point)) (setq beg (1+ beg)) (forward-char 1)) - (funcall func YaTeX-comment-prefix beg (point) YaTeX-uncomment-once))) + (beginning-of-line) + (setq beg (point)) + (save-match-data + (while (and (not (eobp)) + (not (eolp)) + (looking-at YaTeX-comment-prefix)) + (goto-char (match-end 0)))) + (setq beg2 (point)) + (YaTeX-goto-corresponding-environment) + (beginning-of-line) + (if (> p (point)) (setq beg (1+ beg2)) (forward-char 1)) + (funcall func YaTeX-comment-prefix beg (point) YaTeX-uncomment-once))) (message "%sommented out current environment." - (if (eq func 'comment-out-region) "C" "Un-c"))) + (if (string-match "uncom" (symbol-name func)) "Un-c" "C"))) (defun YaTeX-comment-paragraph () "Comment out current paragraph." @@ -2301,7 +2306,7 @@ (t (mark-paragraph) (if (looking-at paragraph-separate) (forward-line 1)) - (comment-out-region "%"))))) + (YaTeX-comment-region-sub "%"))))) (defun YaTeX-uncomment-paragraph () "Uncomment current paragraph." @@ -2323,7 +2328,7 @@ (paragraph-separate paragraph-start)) (mark-paragraph) (if (not (bobp)) (forward-line 1)) - (uncomment-out-region "%" nil nil YaTeX-uncomment-once)) + (YaTeX-uncomment-region-sub "%" nil nil YaTeX-uncomment-once)) (message "This line is not a comment line."))))) (defun YaTeX-remove-prefix (prefix &optional once) diff -r 723f136edde5 -r 9132c20372ec yatexlib.el --- a/yatexlib.el Sun Sep 10 17:03:34 2017 +0859 +++ b/yatexlib.el Sun Sep 10 21:08:14 2017 +0859 @@ -1,7 +1,7 @@ ;;; yatexlib.el --- YaTeX and yahtml common libraries -*- coding: sjis -*- ;;; ;;; (c)1994-2017 by HIROSE Yuuji.[yuuji@yatex.org] -;;; Last modified Sun Sep 10 09:53:33 2017 on firestorm +;;; Last modified Sun Sep 10 18:12:33 2017 on firestorm ;;; $Id$ ;;; Code: @@ -1666,6 +1666,34 @@ (/ (nth 2 before) mil)))))) ;;; +;; Moved from comment.el +;;; +(defun YaTeX-comment-region-sub (string &optional beg end once) + "Inserts STRING at the beginning of every line between BEG and END." + (if (not (stringp string)) (setq string YaTeX-comment-prefix)) + (let ((b (or beg (region-beginning))) (e (or end (region-end)))) + (save-excursion + (goto-char (max b e)) + (if (bolp) + (forward-line -1)) + (save-restriction + (narrow-to-region (min b e) (point)) + (goto-char (point-min)) + (message "%s" string) + (while (re-search-forward "^" nil t) + (insert string)))))) + +(defun YaTeX-uncomment-region-sub (string &optional beg end once) + "Deletes STRING from the beginning of every line between BEG and END." + (save-excursion + (save-restriction + (narrow-to-region (or beg (region-beginning)) (or end (region-end))) + (goto-char (point-min)) + (while (re-search-forward (concat "^" string) nil t) + (replace-match "") + (if once (end-of-line)))))) + +;;; ;; Functions for the Installation time ;;;