yatex
diff yatex.el @ 482:9132c20372ec
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 | 791fd80d22ed |
line diff
1.1 --- a/yatex.el Sun Sep 10 17:03:34 2017 +0859 1.2 +++ b/yatex.el Sun Sep 10 21:08:14 2017 +0859 1.3 @@ -1,14 +1,13 @@ 1.4 ;;; yatex.el --- Yet Another tex-mode for emacs //–ì’¹// -*- coding: sjis -*- 1.5 ;;; (c)1991-2017 by HIROSE Yuuji.[yuuji@yatex.org] 1.6 -;;; Last modified Sun Sep 10 09:51:57 2017 on firestorm 1.7 +;;; Last modified Sun Sep 10 20:30:31 2017 on firestorm 1.8 ;;; $Id$ 1.9 ;;; The latest version of this software is always available at; 1.10 ;;; http://www.yatex.org/ 1.11 1.12 ;;; Code: 1.13 -(require 'comment) 1.14 (require 'yatexlib) 1.15 -(defconst YaTeX-revision-number "1.79.4" 1.16 +(defconst YaTeX-revision-number "1.80" 1.17 "Revision number of running yatex.el") 1.18 1.19 ;---------- Local variables ---------- 1.20 @@ -2256,34 +2255,40 @@ 1.21 it comments out whole environment" 1.22 (interactive "P") 1.23 (if (not (YaTeX-on-begin-end-p)) 1.24 - (comment-out-region 1.25 + (YaTeX-comment-region-sub 1.26 (if alt-prefix 1.27 (read-string-with-history "Insert prefix: ") 1.28 YaTeX-comment-prefix)) 1.29 - (YaTeX-comment-uncomment-env 'comment-out-region))) 1.30 + (YaTeX-comment-uncomment-env 'YaTeX-comment-region-sub))) 1.31 1.32 (defun YaTeX-uncomment-region (alt-prefix) 1.33 "Uncomment out region by '%'." 1.34 (interactive "P") 1.35 (if (not (YaTeX-on-begin-end-p)) 1.36 - (uncomment-out-region 1.37 + (YaTeX-uncomment-region-sub 1.38 (if alt-prefix (read-string-with-history "Remove prefix: ") 1.39 YaTeX-comment-prefix) 1.40 (region-beginning) (region-end) YaTeX-uncomment-once) 1.41 - (YaTeX-comment-uncomment-env 'uncomment-out-region))) 1.42 + (YaTeX-comment-uncomment-env 'YaTeX-uncomment-region-sub))) 1.43 1.44 (defun YaTeX-comment-uncomment-env (func) 1.45 "Comment or uncomment out one LaTeX environment switching function by FUNC." 1.46 - (let (beg (p (point))) 1.47 + (let (beg beg2 (p (point))) 1.48 (save-excursion 1.49 - (beginning-of-line) 1.50 - (setq beg (point)) 1.51 - (YaTeX-goto-corresponding-environment) 1.52 - (beginning-of-line) 1.53 - (if (> p (point)) (setq beg (1+ beg)) (forward-char 1)) 1.54 - (funcall func YaTeX-comment-prefix beg (point) YaTeX-uncomment-once))) 1.55 + (beginning-of-line) 1.56 + (setq beg (point)) 1.57 + (save-match-data 1.58 + (while (and (not (eobp)) 1.59 + (not (eolp)) 1.60 + (looking-at YaTeX-comment-prefix)) 1.61 + (goto-char (match-end 0)))) 1.62 + (setq beg2 (point)) 1.63 + (YaTeX-goto-corresponding-environment) 1.64 + (beginning-of-line) 1.65 + (if (> p (point)) (setq beg (1+ beg2)) (forward-char 1)) 1.66 + (funcall func YaTeX-comment-prefix beg (point) YaTeX-uncomment-once))) 1.67 (message "%sommented out current environment." 1.68 - (if (eq func 'comment-out-region) "C" "Un-c"))) 1.69 + (if (string-match "uncom" (symbol-name func)) "Un-c" "C"))) 1.70 1.71 (defun YaTeX-comment-paragraph () 1.72 "Comment out current paragraph." 1.73 @@ -2301,7 +2306,7 @@ 1.74 (t 1.75 (mark-paragraph) 1.76 (if (looking-at paragraph-separate) (forward-line 1)) 1.77 - (comment-out-region "%"))))) 1.78 + (YaTeX-comment-region-sub "%"))))) 1.79 1.80 (defun YaTeX-uncomment-paragraph () 1.81 "Uncomment current paragraph." 1.82 @@ -2323,7 +2328,7 @@ 1.83 (paragraph-separate paragraph-start)) 1.84 (mark-paragraph) 1.85 (if (not (bobp)) (forward-line 1)) 1.86 - (uncomment-out-region "%" nil nil YaTeX-uncomment-once)) 1.87 + (YaTeX-uncomment-region-sub "%" nil nil YaTeX-uncomment-once)) 1.88 (message "This line is not a comment line."))))) 1.89 1.90 (defun YaTeX-remove-prefix (prefix &optional once)