# HG changeset patch # User yuuji@gentei.org # Date 1274680507 -32400 # Node ID 57d3d9abd661998d61bacaae49dec5b4977825a6 # Parent 4f89dd9d83f2d403f700b1d7fdb8ed1e267cceb0 Search %# built-in value for parent if not found in current buffer. diff -r 4f89dd9d83f2 -r 57d3d9abd661 yatexprc.el --- a/yatexprc.el Fri Feb 12 21:31:45 2010 +0900 +++ b/yatexprc.el Mon May 24 14:55:07 2010 +0900 @@ -2,7 +2,7 @@ ;;; YaTeX process handler. ;;; yatexprc.el ;;; (c)1993-2009 by HIROSE Yuuji.[yuuji@yatex.org] -;;; Last modified Mon Sep 28 10:47:11 2009 on firestorm +;;; Last modified Mon May 24 14:50:24 2010 on firestorm ;;; $Id$ ;(require 'yatex) @@ -811,7 +811,7 @@ (defun YaTeX-visit-main (&optional setbuf) "Switch buffer to main LaTeX source. -Use set-buffer instead of switch-to-buffer if the optional second argument +Use set-buffer instead of switch-to-buffer if the optional argument SETBUF is t(Use it only from Emacs-Lisp program)." (interactive "P") (if (and (interactive-p) setbuf) (setq YaTeX-parent-file nil)) @@ -876,15 +876,25 @@ (defun YaTeX-get-builtin (key) "Read source built-in command of %# usage." - (save-excursion - (goto-char (point-min)) - (if (and (re-search-forward - (concat "^" (regexp-quote (concat "%#" key))) nil t) - (not (eolp))) - (YaTeX-buffer-substring - (progn (skip-chars-forward " " (point-end-of-line))(point)) - (point-end-of-line)) - nil))) + (catch 'builtin + (let ((bl (delq nil (list (current-buffer) + (and YaTeX-parent-file + (get-file-buffer YaTeX-parent-file)))))) + (save-excursion + (while bl + (set-buffer (car bl)) + (save-excursion + (goto-char (point-min)) + (if (and (re-search-forward + (concat "^" (regexp-quote (concat "%#" key))) nil t) + (not (eolp))) + (throw 'builtin + (YaTeX-buffer-substring + (progn + (skip-chars-forward " \t" (point-end-of-line)) + (point)) + (point-end-of-line))))) + (setq bl (cdr bl))))))) (defun YaTeX-save-buffers () "Save buffers whose major-mode is equal to current major-mode."