yatex

diff yatexgen.el @ 295:0d3927b911ce

Changes to 1.77 merged into default branch
author HIROSE Yuuji <yuuji@gentei.org>
date Mon, 01 Apr 2013 22:53:13 +0900
parents 0734be649cb8
children 2a72779d9c50
line diff
     1.1 --- a/yatexgen.el	Thu Dec 25 04:10:32 2003 +0000
     1.2 +++ b/yatexgen.el	Mon Apr 01 22:53:13 2013 +0900
     1.3 @@ -1,16 +1,15 @@
     1.4 -;;; -*- Emacs-Lisp -*-
     1.5 -;;; YaTeX add-in function generator.
     1.6 -;;; yatexgen.el rev.5
     1.7 +;;; yatexgen.el --- YaTeX add-in function generator(rev.5)
     1.8 +
     1.9  ;;; (c)1991-1995,1999,2000 by HIROSE Yuuji.[yuuji@yatex.org]
    1.10 -;;; Last modified Fri Jun 27 12:09:37 2003 on firestorm
    1.11 +;;; Last modified Sat Sep  1 08:10:36 2012 on firestorm
    1.12  ;;; $Id$
    1.13  
    1.14 +;;; Code:
    1.15  (require 'yatex)
    1.16  
    1.17  (defmacro YaTeX-setq (var japanese english)
    1.18    (list 'setq var
    1.19 -	(if YaTeX-japan japanese english))
    1.20 -)
    1.21 +	(if YaTeX-japan japanese english)))
    1.22  
    1.23  (put 'YaTeX-setq 'lisp-indent-hook 1)
    1.24  
    1.25 @@ -29,8 +28,7 @@
    1.26  reading my messages *carefully*, or you'll fail to generate appropriate
    1.27  function.
    1.28  
    1.29 -  Hit return key!"
    1.30 -)
    1.31 +  Hit return key!")
    1.32  
    1.33  (YaTeX-setq YaTeX-generate-start-message
    1.34    "さぁはじめるよ.\n1.登録したい補完をやってみて.
    1.35 @@ -40,33 +38,27 @@
    1.36    "Let's begin completion for which you want to make add-in function.
    1.37  If you want to make add-in function for \\documentstyle input only
    1.38  `\\documentstyle{}' *with* completion of yatex-mode.
    1.39 -If you finish this, please press RET."
    1.40 -)
    1.41 +If you finish this, please press RET.")
    1.42  
    1.43  (YaTeX-setq YaTeX-generate-abort-message
    1.44    "やめた、やめた〜いめんどくせ〜"
    1.45 -  "Aborted."
    1.46 -)
    1.47 +  "Aborted.")
    1.48  
    1.49  (YaTeX-setq YaTeX-generate-same-message
    1.50    "それじゃ、なにも変わってねぇだろーが! やめた。"
    1.51 -  "I found no difference between them.  So I'm quitting."
    1.52 -)
    1.53 +  "I found no difference between them.  So I'm quitting.")
    1.54  
    1.55  (YaTeX-setq YaTeX-generate-invalid-message
    1.56    "それは、ちと無理というものじゃ."
    1.57 -  "It's impossible."
    1.58 -)
    1.59 +  "It's impossible.")
    1.60  
    1.61  (YaTeX-setq YaTeX-generate-idontknow-message
    1.62    "う〜ん、難しくてよくわからないなぁ。ばかでごめんねェ〜"
    1.63 -  "Sorry I can't tell your adding method."
    1.64 -)
    1.65 +  "Sorry I can't tell your adding method.")
    1.66  
    1.67  (YaTeX-setq YaTeX-generate-confirm-message
    1.68    "ということは、付け足したい部分はこれでいいのね"
    1.69 -  "Is it additional string of add-in function?"
    1.70 -)
    1.71 +  "Is it additional string of add-in function?")
    1.72  
    1.73  (YaTeX-setq YaTeX-generate-output-message
    1.74    "2.じゃ、それにくっつけたいものを *カーソルの位置に* 足してみて. 
    1.75 @@ -75,8 +67,7 @@
    1.76  で、またおわったらりたーん!!"
    1.77    "2.Then input additional string *at CURSOR POSITION*
    1.78  According to last example \\documentstyle{},
    1.79 -modify it \\documentstyle[12pt]{}.  RET to finish."
    1.80 -)
    1.81 +modify it \\documentstyle[12pt]{}.  RET to finish.")
    1.82  
    1.83  (YaTeX-setq YaTeX-generate-put-arg-message
    1.84    "3.このうち、キーボードから読み込んで欲しい文字列を順に入れて。
    1.85 @@ -86,8 +77,7 @@
    1.86    "3.In this string, extract string which you want to input from key
    1.87  board with quiry afterwards.  For example, though additional string is
    1.88  \\documentstyle[12pt]{}, but you want enter only `12pt' by hand.
    1.89 -RET to finish!"
    1.90 -)
    1.91 +RET to finish!")
    1.92  
    1.93  (YaTeX-setq YaTeX-generate-read-prompt-message
    1.94    "4.では、あとでこれらの文字列を読み込む時に、どういうプロンプトを
    1.95 @@ -95,8 +85,7 @@
    1.96  さっきの 12pt の部分だったら、『サイズは』とかがおすすめ。"
    1.97    "4.When you use this add-in function afterwards, what message
    1.98  do you like to be prompted with to enter these values.  In last
    1.99 -example `12pt', typical prompt string may be `Size?: '."
   1.100 -)
   1.101 +example `12pt', typical prompt string may be `Size?: '.")
   1.102  
   1.103  (YaTeX-setq YaTeX-generate-done-message
   1.104    "よし! これが、君の作りたかった関数だ。~/.emacs にでも入れてせいぜい
   1.105 @@ -109,34 +98,29 @@
   1.106  for testing of this function please.
   1.107    But you can see this function quite easy, can't you? You had better
   1.108  write your most favorite add-in function yourself!
   1.109 -"
   1.110 -)
   1.111 +")
   1.112  
   1.113  (YaTeX-setq YaTeX-generate-nomatch-message
   1.114    "こらこら、そんな文字列どこにもねーぞ!!"
   1.115 -  "No such string in additional string."
   1.116 -)
   1.117 +  "No such string in additional string.")
   1.118 +
   1.119  (YaTeX-setq YaTeX-generate-buffer
   1.120    "*付加関数生成バッファ*"
   1.121 -  "*Generate-add-in-function*"
   1.122 -)
   1.123 +  "*Generate-add-in-function*")
   1.124  
   1.125  (YaTeX-setq YaTeX-generate-message-buffer
   1.126    "*ご案内*"
   1.127 -  "*Guide*"
   1.128 -)
   1.129 +  "*Guide*")
   1.130  
   1.131  (YaTeX-setq YaTeX-generate-bug-message
   1.132    "ごめ〜ん!! ちょっと、このアドイン関数つくるの失敗しちゃったみたい!!
   1.133  作者まで連絡してくださ〜〜〜い!"
   1.134    "Sorry I failed to make add-in function for you...
   1.135 -Send bug report to me."
   1.136 -)
   1.137 +Send bug report to me.")
   1.138  
   1.139  (YaTeX-setq YaTeX-generate-narrow-message
   1.140    "画面がせますぎるような気がします。"
   1.141 -  "Too narrow screen height."
   1.142 -)
   1.143 +  "Too narrow screen height.")
   1.144  
   1.145  (defvar YaTeX-generate-message-height
   1.146    10 "Window height of YaTeX-generate-message-buffer")
   1.147 @@ -249,8 +233,7 @@
   1.148    (condition-case error
   1.149        (eval-current-buffer)
   1.150      (error (insert YaTeX-generate-bug-message)))
   1.151 -  (pop-to-buffer YaTeX-generate-message-buffer)
   1.152 -)
   1.153 +  (pop-to-buffer YaTeX-generate-message-buffer))
   1.154  
   1.155  (defun YaTeX-generate-parse-add-in (args add-in)
   1.156    "Parse add-in string and extract argument for it.
   1.157 @@ -313,8 +296,7 @@
   1.158      (insert ")\n(concat " (YaTeX-generate-lisp-quote string)
   1.159  	    ")))\n")
   1.160      (indent-region (point-min) (point) nil)
   1.161 -    used)
   1.162 -)
   1.163 +    used))
   1.164  
   1.165  (defun YaTeX-generate-ask-match-position ()
   1.166    "Ask user whether match-position is in his expectation,
   1.167 @@ -331,14 +313,12 @@
   1.168    (insert "\n" (if YaTeX-japan "ここにも対応してるの?"
   1.169  		 "this underlined part too?"))
   1.170    (other-window -1)
   1.171 -  (y-or-n-p (if YaTeX-japan "下線部はあってますか" "Is underline right"))
   1.172 -)
   1.173 +  (y-or-n-p (if YaTeX-japan "下線部はあってますか" "Is underline right")))
   1.174  
   1.175  (defun YaTeX-generate-register-match ()
   1.176    (nconc arg (list (list beg end)))
   1.177    (let ((x beg))
   1.178 -    (while (< x end) (aset used x i)(setq x (1+ x))))
   1.179 -)
   1.180 +    (while (< x end) (aset used x i)(setq x (1+ x)))))
   1.181  
   1.182  (defun YaTeX-generate-display-message (mes &optional bottom)
   1.183    "Display message to generation buffer."
   1.184 @@ -347,8 +327,7 @@
   1.185    (insert "\n\n")
   1.186    (if bottom (recenter (1- bottom)) (recenter 0))
   1.187    (insert mes)
   1.188 -  (other-window -1)
   1.189 -)
   1.190 +  (other-window -1))
   1.191  
   1.192  (defun YaTeX-generate-move-to-add-in-position ()
   1.193    "Move cursor where add-in function should insert string."
   1.194 @@ -366,9 +345,7 @@
   1.195     ((eq YaTeX-current-completion-type 'maketitle)
   1.196      (goto-char (point-max))
   1.197      (if (= (preceding-char) ? )
   1.198 -	(forward-char -1)))
   1.199 -   )
   1.200 -)
   1.201 +	(forward-char -1)))))
   1.202  
   1.203  (defun YaTeX-generate-function-name ()
   1.204    (concat
   1.205 @@ -376,8 +353,7 @@
   1.206     (cond
   1.207      ((eq YaTeX-current-completion-type 'begin) YaTeX-env-name)
   1.208      ((eq YaTeX-current-completion-type 'section) YaTeX-section-name)
   1.209 -    ((eq YaTeX-current-completion-type 'maketitle) YaTeX-single-command)))
   1.210 -)
   1.211 +    ((eq YaTeX-current-completion-type 'maketitle) YaTeX-single-command))))
   1.212  
   1.213  (defun YaTeX-generate-lisp-quote (str)
   1.214    (let ((len (length str))(i 0) (quote ""))
   1.215 @@ -388,8 +364,7 @@
   1.216  	  (setq quote (concat quote "\""))
   1.217  	(setq quote (concat quote (substring str i (1+ i)))))
   1.218        (setq i (1+ i)))
   1.219 -    quote)
   1.220 -)
   1.221 +    quote))
   1.222  
   1.223  (defun YaTeX-generate-quote-quote (str)
   1.224    (let ((len (length str))(i 0) (quote ""))
   1.225 @@ -398,15 +373,13 @@
   1.226  	  (setq quote (concat quote (char-to-string 127))))
   1.227        (setq quote (concat quote (substring str i (1+ i))))
   1.228        (setq i (1+ i)))
   1.229 -    quote)
   1.230 -)
   1.231 +    quote))
   1.232  
   1.233  (defun YaTeX-suppress-sparse-keymap (map)
   1.234    (let ((i ? ))
   1.235      (while (< i 127)
   1.236        (define-key map (char-to-string i) 'undefined)
   1.237 -      (setq i (1+ i))))
   1.238 -)
   1.239 +      (setq i (1+ i)))))
   1.240  
   1.241  ;;;
   1.242  ;; Auto-generate Function for Lispers.
   1.243 @@ -423,8 +396,8 @@
   1.244       ((= c ?p) 'oneof)
   1.245       ((= c ?o) 'coord)
   1.246       ;;((= c ?m) 'macro)
   1.247 -     (t        'quit)))
   1.248 - )
   1.249 +     (t        'quit))))
   1.250 +
   1.251  (defun YaTeX-generate-read-completion-table ()
   1.252    (let ((i 1) cand (cands "(") (cb (current-buffer))
   1.253  	(buf (get-buffer-create " *Candidates*")))
   1.254 @@ -441,8 +414,8 @@
   1.255  	(insert cand "\n"))
   1.256        (kill-buffer buf)))
   1.257      ;;(set-buffer cb)
   1.258 -    (setq YaTeX-generate-current-completion-table (concat cands ")")))
   1.259 -)
   1.260 +    (setq YaTeX-generate-current-completion-table (concat cands ")"))))
   1.261 +
   1.262  (defun YaTeX-generate-corresponding-paren (left)
   1.263    (cond
   1.264     ((equal left "{") "}")
   1.265 @@ -450,16 +423,16 @@
   1.266     ((equal left "(") ")")
   1.267     ((equal left "<") ">")
   1.268     ((equal left "\\begin{") "}")
   1.269 -   (t left))
   1.270 -)
   1.271 +   (t left)))
   1.272 +
   1.273  (defun YaTeX-generate-create-read-string (&optional nth)
   1.274    (concat
   1.275     "(read-string \""
   1.276     (read-string (if nth (format "Prompt for argument#%d: " nth) "Prompt: "))
   1.277     ": \"\n"
   1.278     "\"" (read-string "Default: ") "\""
   1.279 -   ")\n")
   1.280 -)
   1.281 +   ")\n"))
   1.282 +
   1.283  (defun YaTeX-generate-create-completing-read (&optional nth)
   1.284    (prog1
   1.285        (concat
   1.286 @@ -475,21 +448,21 @@
   1.287  	      (cons
   1.288  	       (cons (format "YaTeX-%s-%d" command (or nth 0))
   1.289  		     YaTeX-generate-current-completion-table)
   1.290 -	       YaTeX-generate-variables-for-learning))))
   1.291 -)
   1.292 +	       YaTeX-generate-variables-for-learning)))))
   1.293 +
   1.294  (defun YaTeX-generate-create-read-file-name (&optional nth)
   1.295    (concat
   1.296     "(read-file-name \""
   1.297     (read-string (if nth (format "Prompt for argument#%d: " nth) "Prompt: "))
   1.298 -   ": \" "" \"\" t \"\")\n")
   1.299 -)
   1.300 +   ": \" "" \"\" t \"\")\n"))
   1.301 +
   1.302  (defun YaTeX-generate-create-read-oneof (&optional nth readpos)
   1.303    (concat
   1.304     (if readpos
   1.305         "(YaTeX:read-position \""
   1.306       "(YaTeX:read-oneof \"")
   1.307 -   (read-string "Acceptable characters: " "lcr") "\")\n")
   1.308 -)
   1.309 +   (read-string "Acceptable characters: " "lcr") "\")\n"))
   1.310 +
   1.311  (defun YaTeX-generate-option-type (command)
   1.312    (let ((func (format "YaTeX:%s" command)) leftp
   1.313  	(buf (get-buffer-create YaTeX-generate-buffer)) type (n 1))
   1.314 @@ -546,8 +519,8 @@
   1.315      (goto-char (point-min))
   1.316      (while (not (eobp)) (lisp-indent-line) (forward-line 1))
   1.317      (eval-current-buffer)
   1.318 -    buf)
   1.319 -)
   1.320 +    buf))
   1.321 +
   1.322  (defun YaTeX-generate-argument-type (command argc)
   1.323    "Create an argument-type add-in function."
   1.324    (interactive)
   1.325 @@ -581,8 +554,8 @@
   1.326      (YaTeX-update-table
   1.327       (if (> argc 1) (list command argc) (list command))
   1.328       'section-table 'user-section-table 'tmp-section-table)
   1.329 -    buf)
   1.330 -)
   1.331 +    buf))
   1.332 +
   1.333  (defun YaTeX-generate-simple (&optional command)
   1.334    "Simple but requiring some elisp knowledge add-in generator."
   1.335    (interactive)
   1.336 @@ -607,6 +580,6 @@
   1.337         (YaTeX-generate-option-type command)
   1.338       (YaTeX-generate-argument-type
   1.339        command
   1.340 -      (string-to-int (read-string "How many arguments?: ")))) nil)
   1.341 -)
   1.342 +      (string-to-int (read-string "How many arguments?: ")))) nil))
   1.343 +
   1.344  (provide 'yatexgen)