diff --git a/yatex.el b/yatex.el index 82809ee..7eed1df 100644 --- a/yatex.el +++ b/yatex.el @@ -1,15 +1,15 @@ ;;; -*- Emacs-Lisp -*- ;;; Yet Another tex-mode for emacs - //�쒹// -;;; yatex.el rev. 1.74.3 +;;; yatex.el rev. 1.74.4 ;;; (c)1991-2011 by HIROSE Yuuji.[yuuji@yatex.org] -;;; Last modified Mon Feb 14 12:48:33 2011 on firestorm +;;; Last modified Wed Feb 16 17:23:52 2011 on firestorm ;;; $Id$ ;;; The latest version of this software is always available at; ;;; http://www.yatex.org/ (require 'comment) (require 'yatexlib) -(defconst YaTeX-revision-number "1.74.3" +(defconst YaTeX-revision-number "1.74.4" "Revision number of running yatex.el") ;---------- Local variables ---------- @@ -1528,6 +1528,29 @@ (set-marker e nil)) )))) +(defvar YaTeX-refcommand-def-regexp-default + "label\\|bibitem") +(defvar YaTeX-refcommand-def-regexp-private nil + "*Regexp of defining label commands") +(defvar YaTeX-refcommand-def-regexp + (concat (if YaTeX-refcommand-def-regexp-private + (concat YaTeX-refcommand-def-regexp-private "\\|")) + YaTeX-refcommand-def-regexp-default)) + +(defvar YaTeX-refcommand-ref-regexp-default + "\\(page\\|eq\\|fig\\)?ref\\|cite") +(defvar YaTeX-refcommand-ref-regexp-private nil + "*Regexp of referring label commands") +(defvar YaTeX-refcommand-ref-regexp + (concat (if YaTeX-refcommand-ref-regexp-private + (concat YaTeX-refcommand-ref-regexp-private "\\|")) + YaTeX-refcommand-ref-regexp-default)) + +(defvar YaTeX-refcommand-regexp + (concat YaTeX-refcommand-def-regexp + "\\|" YaTeX-refcommand-ref-regexp) + "Regexp of label defining/referring command name.") + (defun YaTeX-goto-corresponding-label (reverse &optional otherwin) "Jump to corresponding \\label{} and \\ref{} or \\cite and \\bibitem. The default search direction depends on the command at the cursor position. @@ -1543,7 +1566,7 @@ If optional second argument OTHERWIN is non-nil, move to other window." (let ((scmd "") label direc string blist (p (point)) (cb (current-buffer)) - (refcommands "label\\|\\(page\\|eq\\)?ref\\|cite\\|bibitem") + (refcommands YaTeX-refcommand-regexp) (foundmsg (format "Type %s %c to return to original position." (key-description (car diff --git a/yatex.new b/yatex.new index 17e360c..ec8a0fa 100644 --- a/yatex.new +++ b/yatex.new @@ -5,7 +5,8 @@ [prefix] t e �Ń|�C���g�ʒu���܂ފ‹��������‹����^�C�v�Z�b�g�B M-C-SPC �Ŋ‹������łȂ������‹����}�[�N����B [prefix] t d �Ń^�C�v�Z�b�^�N�������̂��� dvipdfmx ���N���B - \label{}�Ń��x��������ꂽ�Ƃ��� \ref{NAME} �������I��kill-ring�lj��B + \label{}�Ń��x��������ꂽ�Ƃ��� \ref{NAME} �������I��kill-ring�ɒlj��B + \bibitem{}����ꂽ�Ƃ��� \cite{TAG} �������I��kill-ring�ɒlj��B === yahtml === [prefix] t �u���E�U���j���[�Ɂun:�V�K�y�[�W�쐬�v��lj�(����)�B [prefix] t j ��lint�R�}���h�� �s�Ŏw��B diff --git a/yatexadd.el b/yatexadd.el index 0f77680..61f8383 100644 --- a/yatexadd.el +++ b/yatexadd.el @@ -2,7 +2,7 @@ ;;; YaTeX add-in functions. ;;; yatexadd.el rev.19 ;;; (c)1991-2011 by HIROSE Yuuji.[yuuji@yatex.org] -;;; Last modified Mon Feb 14 14:48:30 2011 on firestorm +;;; Last modified Wed Feb 16 19:57:26 2011 on firestorm ;;; $Id$ ;;; @@ -742,7 +742,7 @@ "Alist of labeling regexp vs. its group number points to label string. This alist is used in \\ref's argument's completion.") (defvar YaTeX::ref-labeling-regexp-alist-private nil - "*Private extesion to YaTeX::ref-labeling-regexp-alist. + "*Private extension to YaTeX::ref-labeling-regexp-alist. See the documetation of YaTeX::ref-labeling-regexp-alist.") (defvar YaTeX::ref-labeling-regexp-alist (append YaTeX::ref-labeling-regexp-alist-default @@ -1119,12 +1119,86 @@ (bury-buffer YaTeX-label-buffer))) label))))) +(defun YaTeX::label-rename-refs (old new &optional def ref) + "Rename reference tag from OLD to NEW. +Optional arguments DEF and REF specify defining command and +referring command respectively. +--------------------------------------------------------- +CONTROL KEYS - �L�[�̐��� + y Replace �u������ + n Do not replace �u�����Ȃ� + ! Replace All w/o query �c��S�����m�F�Ȃ��Œu�� + r Enter Recursive-edit �ċA�ҏW���[�h�� + q Quit from replacing �����܂łŒu������߂� + +Don't forget to exit from recursive edit by typing \\[exit-recursive-edit] +�ċA�ҏW�ɓ������� \\[exit-recursive-edit] �Ŕ����Y��Ȃ��悤�B" + (save-window-excursion + (catch 'exit + (let*((bufs (YaTeX-yatex-buffer-list)) buf b e + (oldptn (regexp-quote old)) + (sw (selected-window)) + (ptn (concat + "\\(" YaTeX-refcommand-ref-regexp "\\)" + "\\s *{" oldptn "}")) + (useov (fboundp 'make-overlay)) ov + (qmsg "Replace to `%s'? [yn!rq]") + continue ch) + (while bufs + (set-buffer (setq buf (car bufs))) + (save-excursion + (goto-char (point-min)) + (while (re-search-forward ptn nil t) + (goto-char (match-end 1)) + (skip-chars-forward " \t\n{") + (unwind-protect + (if (and + (looking-at oldptn) + (setq b (match-beginning 0) + e (match-end 0)) + (or continue + (catch 'query + (if useov + (if ov (move-overlay ov b e) + (overlay-put + (setq ov (make-overlay b e)) + 'face 'isearch))) + (switch-to-buffer buf) + (while t + (message qmsg new) + (setq ch (read-char)) + (cond + ((= ch ?q) (throw 'exit t)) + ((= ch ?r) + (message + "Exit recursive-edit by `%s'" + (key-description + (where-is-internal + 'exit-recursive-edit '(keymap) t))) + (sleep-for 2) + (recursive-edit)) + ((= ch ?y) (throw 'query t)) + ((= ch ?!) (throw 'query (setq continue t))) + ((= ch ??) + (describe-function + 'YaTeX::label-rename-refs) + (select-window (get-buffer-window "*Help*")) + (search-forward "----") + (forward-line 1) + (set-window-start (selected-window) (point)) + (sit-for 0) + (select-window sw)) + ((= ch ?n) (throw 'query nil))))))) + (replace-match new)) + (and ov (delete-overlay ov))))) + (setq bufs (cdr bufs))))))) + (defun YaTeX::label (argp &optional labname refname) "Read label name and return it with copying \\ref{LABEL-NAME} to kill-ring." (cond ((= argp 1) - (let*((dlab (if (boundp (intern-soft "old")) - old ;if called via YaTeX-change-section (tricky...) + (let*((chmode (boundp (intern-soft "old"))) + (dlab (if chmode old ;if called via YaTeX-change-section (tricky...) (YaTeX::ref-default-label))) (label (read-string (format "New %s name: " (or labname "label")) @@ -1137,7 +1211,8 @@ "��kill-ring�ɓ���܂����Byank(%s)�Ŏ��o���܂��B" " is stored into kill-ring. Paste it by yank(%s)."))) (kill-new refstr) - (message (concat "`%s'" msg) refstr key))) + (message (concat "`%s'" msg) refstr key) + (if chmode (YaTeX::label-rename-refs old label)))) label)))) @@ -1322,13 +1397,6 @@ (fset 'YaTeX::citep 'YaTeX::cite) (fset 'YaTeX::citet 'YaTeX::cite) -(defun YaTeX-yatex-buffer-list () - (save-excursion - (delq nil (mapcar (function (lambda (buf) - (set-buffer buf) - (if (eq major-mode 'yatex-mode) buf))) - (buffer-list))))) - (defun YaTeX-select-other-yatex-buffer () "Select buffer from all yatex-mode's buffers interactivelly." (interactive) diff --git a/yatexlib.el b/yatexlib.el index 58bb761..91f590e 100644 --- a/yatexlib.el +++ b/yatexlib.el @@ -2,7 +2,7 @@ ;;; YaTeX and yahtml common libraries, general functions and definitions ;;; yatexlib.el ;;; (c)1994-2009 by HIROSE Yuuji.[yuuji@yatex.org] -;;; Last modified Sat Sep 11 11:40:11 2010 on firestorm +;;; Last modified Wed Feb 16 19:58:33 2011 on firestorm ;;; $Id$ ;; General variables @@ -665,6 +665,13 @@ (self-insert-command 1) (YaTeX-minibuffer-complete))) +(defun YaTeX-yatex-buffer-list () + (save-excursion + (delq nil (mapcar (function (lambda (buf) + (set-buffer buf) + (if (eq major-mode 'yatex-mode) buf))) + (buffer-list))))) + (defun foreach-buffers (pattern job) "For each buffer which matches with PATTERN, do JOB." (let ((list (buffer-list)))