yatex

changeset 482:9132c20372ec dev

Remove comment.el and incorporate it into yatexlib.el
author HIROSE Yuuji <yuuji@gentei.org>
date Sun, 10 Sep 2017 21:08:14 +0859
parents 723f136edde5
children 6dcd746db62e
files comment.el yatex.el yatexlib.el
diffstat 3 files changed, 51 insertions(+), 104 deletions(-) [+]
line diff
     1.1 --- a/comment.el	Sun Sep 10 17:03:34 2017 +0859
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,86 +0,0 @@
     1.4 -;;; -*- Emacs-Lisp -*-
     1.5 -;;; comment/uncomment region for emacs.
     1.6 -;;; comment.el rev.0.1
     1.7 -;;; (c) 1992, 2002 by HIROSE Yuuji.(yuuji@yatex.org)
     1.8 -;;; Last modified Mon Nov 25 18:33:23 2002 on firestorm
     1.9 -
    1.10 -;;; Rename `comment-region' to `comment-out-region' for standard
    1.11 -;;; Emacs-19 function.
    1.12 -
    1.13 -(provide 'comment)
    1.14 -
    1.15 -(defvar current-comment-prefix "> " "*Default prefix string")
    1.16 -
    1.17 -(defun cite-region (beg end)
    1.18 -  (save-excursion
    1.19 -    (goto-char (max beg end))
    1.20 -    (if (bolp)
    1.21 -	(forward-line -1))
    1.22 -    (if (string= string "") (setq string current-comment-prefix)
    1.23 -      (setq current-comment-prefix string))
    1.24 -    (save-restriction 
    1.25 -      (narrow-to-region (min beg end) (point))
    1.26 -      (goto-char (point-min))
    1.27 -      (message "%s" string)
    1.28 -      (while (re-search-forward "^" nil t)
    1.29 -	(replace-match string))
    1.30 -      ))
    1.31 -)
    1.32 -
    1.33 -(defun comment-out-region (string &optional beg end once)
    1.34 -  "Inserts STRING at the beginning of every line in the region specified
    1.35 -BEG and END.
    1.36 -Called interactively, STRING defaults to comment-start (or '> ' if
    1.37 -none is defined) unless a prefix argument is given, in which case it
    1.38 -prompts for a string.  Optional second argument ONCE is only for
    1.39 -compatibility for uncomment-region.  It has no means now."
    1.40 -  (interactive
    1.41 -   (list (if current-prefix-arg
    1.42 -	     (read-string 
    1.43 -	      (concat "String to insert"
    1.44 -		      (format "(default \"%s\")" current-comment-prefix
    1.45 -			      " ")
    1.46 -		      ": "))
    1.47 -	   current-comment-prefix)))
    1.48 -  (if (not (stringp string)) (setq string current-comment-prefix))
    1.49 -  (cite-region (or beg (region-beginning)) (or end (region-end)))
    1.50 -)
    1.51 -
    1.52 -
    1.53 -(defun uncomment-out-region (string &optional beg end once)
    1.54 -  "Deletes STRING from the beginning of every line in the region.
    1.55 -Called interactively, STRING defaults to comment-start (or '> ' if
    1.56 -none is defined) unless a prefix argument is given, in which case it
    1.57 -prompts for a string.  Optional second argument ONCE restricts
    1.58 -deletion to first occurance of STRING on each line."
    1.59 -  (interactive
    1.60 -   (list (if current-prefix-arg
    1.61 -	     (read-string 
    1.62 -	      (concat "String to delete"
    1.63 -		      (format "(default \"%s\")" current-comment-prefix
    1.64 -			      " ")
    1.65 -		      ": "))
    1.66 -	   current-comment-prefix)))
    1.67 -  (if (not (stringp string)) (setq string current-comment-prefix))
    1.68 -  (save-excursion
    1.69 -    (save-restriction 
    1.70 -      (narrow-to-region (or beg (region-beginning)) (or end (region-end)))
    1.71 -      (goto-char (point-min))
    1.72 -      (while (re-search-forward (concat "^" string) nil t)
    1.73 -	(replace-match "")
    1.74 -	(if once (end-of-line)))
    1.75 -      ))
    1.76 -)
    1.77 -
    1.78 -(defun cite-file (filename)
    1.79 -  "insert the file with citation string."
    1.80 -  (interactive "FCite-file: ")
    1.81 -  (let*
    1.82 -      ((string
    1.83 -	(read-string
    1.84 -	 (format "Citation string (default \"%s\"): " current-comment-prefix)
    1.85 -	 ))
    1.86 -       (ins-tail (car (cdr (insert-file-contents filename)))))
    1.87 -    (save-excursion
    1.88 -      (cite-region (point) (+ (point) ins-tail))))
    1.89 -)
     2.1 --- a/yatex.el	Sun Sep 10 17:03:34 2017 +0859
     2.2 +++ b/yatex.el	Sun Sep 10 21:08:14 2017 +0859
     2.3 @@ -1,14 +1,13 @@
     2.4  ;;; yatex.el --- Yet Another tex-mode for emacs //–ì’¹// -*- coding: sjis -*-
     2.5  ;;; (c)1991-2017 by HIROSE Yuuji.[yuuji@yatex.org]
     2.6 -;;; Last modified Sun Sep 10 09:51:57 2017 on firestorm
     2.7 +;;; Last modified Sun Sep 10 20:30:31 2017 on firestorm
     2.8  ;;; $Id$
     2.9  ;;; The latest version of this software is always available at;
    2.10  ;;; http://www.yatex.org/
    2.11  
    2.12  ;;; Code:
    2.13 -(require 'comment)
    2.14  (require 'yatexlib)
    2.15 -(defconst YaTeX-revision-number "1.79.4"
    2.16 +(defconst YaTeX-revision-number "1.80"
    2.17    "Revision number of running yatex.el")
    2.18  
    2.19  ;---------- Local variables ----------
    2.20 @@ -2256,34 +2255,40 @@
    2.21  it comments out whole environment"
    2.22    (interactive "P")
    2.23    (if (not (YaTeX-on-begin-end-p))
    2.24 -      (comment-out-region
    2.25 +      (YaTeX-comment-region-sub
    2.26         (if alt-prefix
    2.27  	   (read-string-with-history "Insert prefix: ")
    2.28  	 YaTeX-comment-prefix))
    2.29 -    (YaTeX-comment-uncomment-env 'comment-out-region)))
    2.30 +    (YaTeX-comment-uncomment-env 'YaTeX-comment-region-sub)))
    2.31  
    2.32  (defun YaTeX-uncomment-region (alt-prefix)
    2.33    "Uncomment out region by '%'."
    2.34    (interactive "P")
    2.35    (if (not (YaTeX-on-begin-end-p))
    2.36 -      (uncomment-out-region
    2.37 +      (YaTeX-uncomment-region-sub
    2.38         (if alt-prefix (read-string-with-history "Remove prefix: ")
    2.39  	 YaTeX-comment-prefix)
    2.40         (region-beginning) (region-end) YaTeX-uncomment-once)
    2.41 -    (YaTeX-comment-uncomment-env 'uncomment-out-region)))
    2.42 +    (YaTeX-comment-uncomment-env 'YaTeX-uncomment-region-sub)))
    2.43  
    2.44  (defun YaTeX-comment-uncomment-env (func)
    2.45    "Comment or uncomment out one LaTeX environment switching function by FUNC."
    2.46 -  (let (beg (p (point)))
    2.47 +  (let (beg beg2 (p (point)))
    2.48      (save-excursion
    2.49 -      (beginning-of-line)
    2.50 -      (setq beg (point))
    2.51 -      (YaTeX-goto-corresponding-environment)
    2.52 -      (beginning-of-line)
    2.53 -      (if (> p (point)) (setq beg (1+ beg)) (forward-char 1))
    2.54 -      (funcall func YaTeX-comment-prefix beg (point) YaTeX-uncomment-once)))
    2.55 +	(beginning-of-line)
    2.56 +	(setq beg (point))
    2.57 +	(save-match-data
    2.58 +	  (while (and (not (eobp))
    2.59 +		      (not (eolp))
    2.60 +		      (looking-at YaTeX-comment-prefix))
    2.61 +	    (goto-char (match-end 0))))
    2.62 +	(setq beg2 (point))
    2.63 +	(YaTeX-goto-corresponding-environment)
    2.64 +	(beginning-of-line)
    2.65 +	(if (> p (point)) (setq beg (1+ beg2)) (forward-char 1))
    2.66 +	(funcall func YaTeX-comment-prefix beg (point) YaTeX-uncomment-once)))
    2.67    (message "%sommented out current environment."
    2.68 -	   (if (eq func 'comment-out-region) "C" "Un-c")))
    2.69 +	   (if (string-match "uncom" (symbol-name func)) "Un-c" "C")))
    2.70  
    2.71  (defun YaTeX-comment-paragraph ()
    2.72    "Comment out current paragraph."
    2.73 @@ -2301,7 +2306,7 @@
    2.74       (t
    2.75        (mark-paragraph)
    2.76        (if (looking-at paragraph-separate) (forward-line 1))
    2.77 -      (comment-out-region "%")))))
    2.78 +      (YaTeX-comment-region-sub "%")))))
    2.79  
    2.80  (defun YaTeX-uncomment-paragraph ()
    2.81    "Uncomment current paragraph."
    2.82 @@ -2323,7 +2328,7 @@
    2.83  		(paragraph-separate paragraph-start))
    2.84  	    (mark-paragraph)
    2.85  	    (if (not (bobp)) (forward-line 1))
    2.86 -	    (uncomment-out-region "%" nil nil YaTeX-uncomment-once))
    2.87 +	    (YaTeX-uncomment-region-sub "%" nil nil YaTeX-uncomment-once))
    2.88  	(message "This line is not a comment line.")))))
    2.89  
    2.90  (defun YaTeX-remove-prefix (prefix &optional once)
     3.1 --- a/yatexlib.el	Sun Sep 10 17:03:34 2017 +0859
     3.2 +++ b/yatexlib.el	Sun Sep 10 21:08:14 2017 +0859
     3.3 @@ -1,7 +1,7 @@
     3.4  ;;; yatexlib.el --- YaTeX and yahtml common libraries -*- coding: sjis -*-
     3.5  ;;; 
     3.6  ;;; (c)1994-2017 by HIROSE Yuuji.[yuuji@yatex.org]
     3.7 -;;; Last modified Sun Sep 10 09:53:33 2017 on firestorm
     3.8 +;;; Last modified Sun Sep 10 18:12:33 2017 on firestorm
     3.9  ;;; $Id$
    3.10  
    3.11  ;;; Code:
    3.12 @@ -1666,6 +1666,34 @@
    3.13  	      (/ (nth 2 before) mil))))))
    3.14  
    3.15  ;;;
    3.16 +;; Moved from comment.el
    3.17 +;;;
    3.18 +(defun YaTeX-comment-region-sub (string &optional beg end once)
    3.19 +  "Inserts STRING at the beginning of every line between BEG and END."
    3.20 +  (if (not (stringp string)) (setq string YaTeX-comment-prefix))
    3.21 +  (let ((b (or beg (region-beginning))) (e (or end (region-end))))
    3.22 +    (save-excursion
    3.23 +      (goto-char (max b e))
    3.24 +      (if (bolp)
    3.25 +	  (forward-line -1))
    3.26 +      (save-restriction 
    3.27 +	(narrow-to-region (min b e) (point))
    3.28 +	(goto-char (point-min))
    3.29 +	(message "%s" string)
    3.30 +	(while (re-search-forward "^" nil t)
    3.31 +	  (insert string))))))
    3.32 +
    3.33 +(defun YaTeX-uncomment-region-sub (string &optional beg end once)
    3.34 +  "Deletes STRING from the beginning of every line between BEG and END."
    3.35 +  (save-excursion
    3.36 +    (save-restriction 
    3.37 +      (narrow-to-region (or beg (region-beginning)) (or end (region-end)))
    3.38 +      (goto-char (point-min))
    3.39 +      (while (re-search-forward (concat "^" string) nil t)
    3.40 +	(replace-match "")
    3.41 +	(if once (end-of-line))))))
    3.42 +
    3.43 +;;;
    3.44  ;; Functions for the Installation time
    3.45  ;;;
    3.46