yatex
diff yatexlib.el @ 225:bd9dc9d53a3a
New func. YaTeX-getset-builtin introduced to update builtin line interactive.
author | yuuji@gentei.org |
---|---|
date | Mon, 23 Jan 2012 00:11:09 +0900 |
parents | cf7352dfa40c |
children | 60844b664f54 |
line diff
1.1 --- a/yatexlib.el Mon Jan 09 20:21:13 2012 +0900 1.2 +++ b/yatexlib.el Mon Jan 23 00:11:09 2012 +0900 1.3 @@ -2,7 +2,7 @@ 1.4 ;;; YaTeX and yahtml common libraries, general functions and definitions 1.5 ;;; yatexlib.el 1.6 ;;; (c)1994-2012 by HIROSE Yuuji.[yuuji@yatex.org] 1.7 -;;; Last modified Mon Jan 9 20:20:09 2012 on firestorm 1.8 +;;; Last modified Mon Jan 23 00:09:36 2012 on firestorm 1.9 ;;; $Id$ 1.10 1.11 ;; General variables 1.12 @@ -1084,16 +1084,18 @@ 1.13 (get-file-buffer pf) 1.14 (switch-to-buffer (get-file-buffer pf))))) 1.15 1.16 -(defun YaTeX-get-builtin (key) 1.17 +(defun YaTeX-getset-builtin (key &optional value) 1.18 "Read source built-in command of %# usage." 1.19 (catch 'builtin 1.20 - (let ((bl (delq nil (list (current-buffer) 1.21 + (let*((bl (delq nil (list (current-buffer) 1.22 (and YaTeX-parent-file 1.23 (get-file-buffer YaTeX-parent-file))))) 1.24 - (leader (or (cdr-safe (assq major-mode 1.25 - '((yatex-mode . "%#") 1.26 - (yahtml-mode . "<!-- #")))) 1.27 - ""))) 1.28 + (tuple (cdr (assq major-mode 1.29 + '((yatex-mode "%#" . "\n") 1.30 + (yahtml-mode "<!-- #" . "[ \t]*-->\\|\n"))))) 1.31 + (leader (or (car tuple) "")) 1.32 + (closer (or (cdr tuple) "")) 1.33 + (prompt (format "Built-in for %s: " key))) 1.34 (save-excursion 1.35 (while bl 1.36 (set-buffer (car bl)) 1.37 @@ -1103,17 +1105,35 @@ 1.38 (concat "^" (regexp-quote (concat leader key))) nil t) 1.39 (not (eolp))) 1.40 (throw 'builtin 1.41 - (YaTeX-buffer-substring 1.42 - (progn 1.43 - (skip-chars-forward " \t" (point-end-of-line)) 1.44 - (point)) 1.45 - (if (string< "" comment-end) 1.46 - (progn 1.47 - (search-forward 1.48 - comment-end (point-end-of-line) t) 1.49 - (match-beginning 0)) 1.50 - (point-end-of-line)))))) 1.51 - (setq bl (cdr bl))))))) 1.52 + (let (b e w) 1.53 + (skip-chars-forward " \t" (point-end-of-line)) 1.54 + (setq b (point) 1.55 + e (if (re-search-forward closer nil t) 1.56 + (match-beginning 0) 1.57 + (point-end-of-line)) 1.58 + w (YaTeX-buffer-substring b e)) 1.59 + (if (null value) 1.60 + w 1.61 + (delete-region b e) 1.62 + (goto-char b) 1.63 + (if (symbolp value) 1.64 + (setq value (read-string prompt w))) 1.65 + (insert value) 1.66 + value))))) 1.67 + (setq bl (cdr bl))) 1.68 + ; not found 1.69 + (if (null value) 1.70 + nil ;not set mode, return simply nil 1.71 + (if (symbolp value) 1.72 + (setq value (read-string prompt))) 1.73 + (save-excursion 1.74 + (goto-char (point-min)) 1.75 + (insert leader key " " value "\n") 1.76 + value)))))) ;on set mode, return set value 1.77 + 1.78 +(defun YaTeX-get-builtin (key) 1.79 + "Read source built-in command of %# usage." 1.80 + (YaTeX-getset-builtin key)) 1.81 1.82 ;;;VER2 1.83 (defun YaTeX-insert-struc (what env)