Mercurial > hgrepos > hgweb.cgi > yatex
comparison yatexlib.el @ 225:bd9dc9d53a3a dev
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 |
comparison
equal
deleted
inserted
replaced
224:9705855793ca | 225:bd9dc9d53a3a |
---|---|
1 ;;; -*- Emacs-Lisp -*- | 1 ;;; -*- Emacs-Lisp -*- |
2 ;;; YaTeX and yahtml common libraries, general functions and definitions | 2 ;;; YaTeX and yahtml common libraries, general functions and definitions |
3 ;;; yatexlib.el | 3 ;;; yatexlib.el |
4 ;;; (c)1994-2012 by HIROSE Yuuji.[yuuji@yatex.org] | 4 ;;; (c)1994-2012 by HIROSE Yuuji.[yuuji@yatex.org] |
5 ;;; Last modified Mon Jan 9 20:20:09 2012 on firestorm | 5 ;;; Last modified Mon Jan 23 00:09:36 2012 on firestorm |
6 ;;; $Id$ | 6 ;;; $Id$ |
7 | 7 |
8 ;; General variables | 8 ;; General variables |
9 (defvar YaTeX-dos (memq system-type '(ms-dos windows-nt OS/2))) | 9 (defvar YaTeX-dos (memq system-type '(ms-dos windows-nt OS/2))) |
10 (defvar YaTeX-macos (memq system-type '(darwin))) | 10 (defvar YaTeX-macos (memq system-type '(darwin))) |
1082 (kill-buffer buffer) | 1082 (kill-buffer buffer) |
1083 (and pf | 1083 (and pf |
1084 (get-file-buffer pf) | 1084 (get-file-buffer pf) |
1085 (switch-to-buffer (get-file-buffer pf))))) | 1085 (switch-to-buffer (get-file-buffer pf))))) |
1086 | 1086 |
1087 (defun YaTeX-get-builtin (key) | 1087 (defun YaTeX-getset-builtin (key &optional value) |
1088 "Read source built-in command of %# usage." | 1088 "Read source built-in command of %# usage." |
1089 (catch 'builtin | 1089 (catch 'builtin |
1090 (let ((bl (delq nil (list (current-buffer) | 1090 (let*((bl (delq nil (list (current-buffer) |
1091 (and YaTeX-parent-file | 1091 (and YaTeX-parent-file |
1092 (get-file-buffer YaTeX-parent-file))))) | 1092 (get-file-buffer YaTeX-parent-file))))) |
1093 (leader (or (cdr-safe (assq major-mode | 1093 (tuple (cdr (assq major-mode |
1094 '((yatex-mode . "%#") | 1094 '((yatex-mode "%#" . "\n") |
1095 (yahtml-mode . "<!-- #")))) | 1095 (yahtml-mode "<!-- #" . "[ \t]*-->\\|\n"))))) |
1096 ""))) | 1096 (leader (or (car tuple) "")) |
1097 (closer (or (cdr tuple) "")) | |
1098 (prompt (format "Built-in for %s: " key))) | |
1097 (save-excursion | 1099 (save-excursion |
1098 (while bl | 1100 (while bl |
1099 (set-buffer (car bl)) | 1101 (set-buffer (car bl)) |
1100 (save-excursion | 1102 (save-excursion |
1101 (goto-char (point-min)) | 1103 (goto-char (point-min)) |
1102 (if (and (re-search-forward | 1104 (if (and (re-search-forward |
1103 (concat "^" (regexp-quote (concat leader key))) nil t) | 1105 (concat "^" (regexp-quote (concat leader key))) nil t) |
1104 (not (eolp))) | 1106 (not (eolp))) |
1105 (throw 'builtin | 1107 (throw 'builtin |
1106 (YaTeX-buffer-substring | 1108 (let (b e w) |
1107 (progn | 1109 (skip-chars-forward " \t" (point-end-of-line)) |
1108 (skip-chars-forward " \t" (point-end-of-line)) | 1110 (setq b (point) |
1109 (point)) | 1111 e (if (re-search-forward closer nil t) |
1110 (if (string< "" comment-end) | 1112 (match-beginning 0) |
1111 (progn | 1113 (point-end-of-line)) |
1112 (search-forward | 1114 w (YaTeX-buffer-substring b e)) |
1113 comment-end (point-end-of-line) t) | 1115 (if (null value) |
1114 (match-beginning 0)) | 1116 w |
1115 (point-end-of-line)))))) | 1117 (delete-region b e) |
1116 (setq bl (cdr bl))))))) | 1118 (goto-char b) |
1119 (if (symbolp value) | |
1120 (setq value (read-string prompt w))) | |
1121 (insert value) | |
1122 value))))) | |
1123 (setq bl (cdr bl))) | |
1124 ; not found | |
1125 (if (null value) | |
1126 nil ;not set mode, return simply nil | |
1127 (if (symbolp value) | |
1128 (setq value (read-string prompt))) | |
1129 (save-excursion | |
1130 (goto-char (point-min)) | |
1131 (insert leader key " " value "\n") | |
1132 value)))))) ;on set mode, return set value | |
1133 | |
1134 (defun YaTeX-get-builtin (key) | |
1135 "Read source built-in command of %# usage." | |
1136 (YaTeX-getset-builtin key)) | |
1117 | 1137 |
1118 ;;;VER2 | 1138 ;;;VER2 |
1119 (defun YaTeX-insert-struc (what env) | 1139 (defun YaTeX-insert-struc (what env) |
1120 (cond | 1140 (cond |
1121 ((eq what 'begin) | 1141 ((eq what 'begin) |