diff options
| author | Joakim Verona | 2013-06-12 23:08:43 +0200 |
|---|---|---|
| committer | Joakim Verona | 2013-06-12 23:08:43 +0200 |
| commit | dd7febaa6c58b6c0163ab0f7344ea70b51614460 (patch) | |
| tree | 903203174d5b80393703f17acecb9affd6ae5dfe | |
| parent | 68e305005fbc03f98e7b2e9808d482a3a80146ea (diff) | |
| parent | 868490bbe111400d4a33e0e4e0ad06e3b096a0ce (diff) | |
| download | emacs-dd7febaa6c58b6c0163ab0f7344ea70b51614460.tar.gz emacs-dd7febaa6c58b6c0163ab0f7344ea70b51614460.zip | |
merge upstream
| -rw-r--r-- | .gitignore | 6 | ||||
| -rwxr-xr-x | autogen/configure | 2 | ||||
| -rw-r--r-- | doc/emacs/ChangeLog | 5 | ||||
| -rw-r--r-- | doc/emacs/vc1-xtra.texi | 49 | ||||
| -rw-r--r-- | lisp/ChangeLog | 39 | ||||
| -rw-r--r-- | lisp/ibuf-ext.el | 2 | ||||
| -rw-r--r-- | lisp/international/mule.el | 2 | ||||
| -rw-r--r-- | lisp/mail/reporter.el | 8 | ||||
| -rw-r--r-- | lisp/textmodes/reftex-cite.el | 129 | ||||
| -rw-r--r-- | lisp/textmodes/reftex-parse.el | 154 | ||||
| -rw-r--r-- | lisp/vc/vc-cvs.el | 2 | ||||
| -rw-r--r-- | lisp/vc/vc-hooks.el | 2 | ||||
| -rw-r--r-- | test/ChangeLog | 9 | ||||
| -rw-r--r-- | test/automated/reftex-tests.el | 201 |
14 files changed, 430 insertions, 180 deletions
diff --git a/.gitignore b/.gitignore index 50470179e38..1ee08d84907 100644 --- a/.gitignore +++ b/.gitignore | |||
| @@ -10,12 +10,10 @@ lib/Makefile.in | |||
| 10 | src/config.in | 10 | src/config.in |
| 11 | autom4te.cache | 11 | autom4te.cache |
| 12 | makefile | 12 | makefile |
| 13 | TAGS | ||
| 13 | *~ | 14 | *~ |
| 14 | /README.W32 | 15 | /README.W32 |
| 15 | 16 | ||
| 16 | /bin/ | 17 | /bin/ |
| 17 | /site-lisp/ | 18 | /site-lisp/ |
| 18 | *.o | 19 | /leim/ja-dic/ |
| 19 | *.elc | ||
| 20 | .bzr | ||
| 21 | *# \ No newline at end of file | ||
diff --git a/autogen/configure b/autogen/configure index cc2fafb3803..5cad2fefd24 100755 --- a/autogen/configure +++ b/autogen/configure | |||
| @@ -4355,7 +4355,7 @@ this option's value should be \`yes', \`no', \`gfile', \`inotify' or \`w32'. | |||
| 4355 | with_file_notification=$val | 4355 | with_file_notification=$val |
| 4356 | 4356 | ||
| 4357 | else | 4357 | else |
| 4358 | with_file_notification=yes | 4358 | with_file_notification=$with_features |
| 4359 | fi | 4359 | fi |
| 4360 | 4360 | ||
| 4361 | 4361 | ||
diff --git a/doc/emacs/ChangeLog b/doc/emacs/ChangeLog index 6f2d9517df7..f56f2f51e07 100644 --- a/doc/emacs/ChangeLog +++ b/doc/emacs/ChangeLog | |||
| @@ -3,6 +3,11 @@ | |||
| 3 | * maintaining.texi (VC Directory Commands): Copyedit. | 3 | * maintaining.texi (VC Directory Commands): Copyedit. |
| 4 | (Branches): Put back milder version of pre 2013-06-07 text. | 4 | (Branches): Put back milder version of pre 2013-06-07 text. |
| 5 | 5 | ||
| 6 | 2013-06-09 Xue Fuqiao <xfq.free@gmail.com> | ||
| 7 | |||
| 8 | * vc1-xtra.texi (Revision Tags): Add a cross reference. | ||
| 9 | (CVS Options): Fix the default value of `vc-cvs-stay-local'. | ||
| 10 | |||
| 6 | 2013-06-07 Xue Fuqiao <xfq.free@gmail.com> | 11 | 2013-06-07 Xue Fuqiao <xfq.free@gmail.com> |
| 7 | 12 | ||
| 8 | * maintaining.texi (Branches): Remove text copied from other sources. | 13 | * maintaining.texi (Branches): Remove text copied from other sources. |
diff --git a/doc/emacs/vc1-xtra.texi b/doc/emacs/vc1-xtra.texi index 4e701a580a8..96e171855a5 100644 --- a/doc/emacs/vc1-xtra.texi +++ b/doc/emacs/vc1-xtra.texi | |||
| @@ -199,21 +199,28 @@ through VC@. Most later systems (including CVS, Subversion, bzr, git, | |||
| 199 | and hg) have a native tag facility, and VC uses it where available; | 199 | and hg) have a native tag facility, and VC uses it where available; |
| 200 | those tags will be visible even when you bypass VC. | 200 | those tags will be visible even when you bypass VC. |
| 201 | 201 | ||
| 202 | In a file-oriented VCS, when you rename a registered file you need | 202 | In file-based version control systems, when you rename a registered |
| 203 | to rename its master along with it; the command @code{vc-rename-file} | 203 | file you need to rename its master along with it; the command |
| 204 | will do this automatically. If you are using SCCS, you must also | 204 | @code{vc-rename-file} will do this automatically |
| 205 | update the records of the tag, to mention the file by its new name | 205 | @iftex |
| 206 | (@code{vc-rename-file} does this, too). An old tag that refers to a | 206 | (@pxref{VC Delete/Rename,,,emacs, the Emacs Manual}). |
| 207 | master file that no longer exists under the recorded name is invalid; | 207 | @end iftex |
| 208 | VC can no longer retrieve it. It would be beyond the scope of this | 208 | @ifnottex |
| 209 | manual to explain enough about RCS and SCCS to explain how to update | 209 | (@pxref{VC Delete/Rename}). |
| 210 | the tags by hand. Using @code{vc-rename-file} makes the tag remain | 210 | @end ifnottex |
| 211 | valid for retrieval, but it does not solve all problems. For example, | 211 | If you are using SCCS, you must also update the records of the tag, to |
| 212 | some of the files in your program probably refer to others by name. | 212 | mention the file by its new name (@code{vc-rename-file} does this, |
| 213 | At the very least, the makefile probably mentions the file that you | 213 | too). An old tag that refers to a master file that no longer exists |
| 214 | renamed. If you retrieve an old tag, the renamed file is retrieved | 214 | under the recorded name is invalid; VC can no longer retrieve it. It |
| 215 | under its new name, which is not the name that the makefile expects. | 215 | would be beyond the scope of this manual to explain enough about RCS |
| 216 | So the program won't really work as retrieved. | 216 | and SCCS to explain how to update the tags by hand. Using |
| 217 | @code{vc-rename-file} makes the tag remain valid for retrieval, but it | ||
| 218 | does not solve all problems. For example, some of the files in your | ||
| 219 | program probably refer to others by name. At the very least, the | ||
| 220 | makefile probably mentions the file that you renamed. If you retrieve | ||
| 221 | an old tag, the renamed file is retrieved under its new name, which is | ||
| 222 | not the name that the makefile expects. So the program won't really | ||
| 223 | work as retrieved. | ||
| 217 | 224 | ||
| 218 | @node Version Headers | 225 | @node Version Headers |
| 219 | @subsubsection Inserting Version Control Headers | 226 | @subsubsection Inserting Version Control Headers |
| @@ -377,12 +384,12 @@ ends that support it, including CVS@. In the following, we will talk | |||
| 377 | only about @code{vc-cvs-stay-local}, but everything applies to | 384 | only about @code{vc-cvs-stay-local}, but everything applies to |
| 378 | @code{vc-stay-local} as well. | 385 | @code{vc-stay-local} as well. |
| 379 | 386 | ||
| 380 | If @code{vc-cvs-stay-local} is @code{t} (the default), VC determines | 387 | If @code{vc-cvs-stay-local} is @code{only-file} (the default), VC |
| 381 | the version control status of each file using only the entry in the | 388 | determines the version control status of each file using only the |
| 382 | local CVS subdirectory and the information returned by previous CVS | 389 | entry in the local CVS subdirectory and the information returned by |
| 383 | commands. As a consequence, if you have modified a file and somebody | 390 | previous CVS commands. As a consequence, if you have modified a file |
| 384 | else has checked in other changes, you will not be notified of the | 391 | and somebody else has checked in other changes, you will not be |
| 385 | conflict until you try to commit. | 392 | notified of the conflict until you try to commit. |
| 386 | 393 | ||
| 387 | If you change @code{vc-cvs-stay-local} to @code{nil}, VC queries the | 394 | If you change @code{vc-cvs-stay-local} to @code{nil}, VC queries the |
| 388 | remote repository @emph{before} it decides what to do in | 395 | remote repository @emph{before} it decides what to do in |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ae429db7a7a..48124b85fe4 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,37 @@ | |||
| 1 | 2013-06-12 Grégoire Jadi <daimrod@gmail.com> | ||
| 2 | |||
| 3 | * mail/reporter.el (reporter-submit-bug-report): | ||
| 4 | Handle missing package-name. (Bug#14600) | ||
| 5 | |||
| 6 | 2013-06-12 Rüdiger Sonderfeld <ruediger@c-plusplus.de> | ||
| 7 | |||
| 8 | * textmodes/reftex-cite.el (reftex-cite-regexp-hist) | ||
| 9 | (reftex-citation-prompt, reftex-default-bibliography) | ||
| 10 | (reftex-bib-or-thebib, reftex-get-bibfile-list) | ||
| 11 | (reftex-pop-to-bibtex-entry, reftex-extract-bib-entries) | ||
| 12 | (reftex-bib-sort-author, reftex-bib-sort-year) | ||
| 13 | (reftex-bib-sort-year-reverse, reftex-get-crossref-alist) | ||
| 14 | (reftex-extract-bib-entries-from-thebibliography) | ||
| 15 | (reftex-get-bibkey-default, reftex-get-bib-names) | ||
| 16 | (reftex-parse-bibtex-entry, reftex-get-bib-field) | ||
| 17 | (reftex-format-bib-entry, reftex-parse-bibitem) | ||
| 18 | (reftex-format-bibitem, reftex-do-citation) | ||
| 19 | (reftex-figure-out-cite-format, reftex-offer-bib-menu) | ||
| 20 | (reftex-restrict-bib-matches, reftex-extract-bib-file) | ||
| 21 | (reftex-insert-bib-matches, reftex-format-citation) | ||
| 22 | (reftex-make-cite-echo-string, reftex-bibtex-selection-callback) | ||
| 23 | (reftex-create-bibtex-file): Add docstrings, mostly by converting | ||
| 24 | existing comments into docstrings. | ||
| 25 | |||
| 26 | 2013-06-12 Xue Fuqiao <xfq.free@gmail.com> | ||
| 27 | |||
| 28 | * ibuf-ext.el (ibuffer-mark-help-buffers): Doc fix. | ||
| 29 | |||
| 30 | 2013-06-12 Andreas Schwab <schwab@suse.de> | ||
| 31 | |||
| 32 | * international/mule.el (auto-coding-alist): Use utf-8-emacs-unix | ||
| 33 | for auto-save files. | ||
| 34 | |||
| 1 | 2013-06-12 Glenn Morris <rgm@gnu.org> | 35 | 2013-06-12 Glenn Morris <rgm@gnu.org> |
| 2 | 36 | ||
| 3 | * ido.el (ido-delete-ignored-files): Remove. | 37 | * ido.el (ido-delete-ignored-files): Remove. |
| @@ -130,6 +164,11 @@ | |||
| 130 | * epa.el (epa-read-file-name): New function. (Bug#14510) | 164 | * epa.el (epa-read-file-name): New function. (Bug#14510) |
| 131 | (epa-decrypt-file): Make plain-file optional. Use epa-read-file-name. | 165 | (epa-decrypt-file): Make plain-file optional. Use epa-read-file-name. |
| 132 | 166 | ||
| 167 | 2013-06-09 Xue Fuqiao <xfq.free@gmail.com> | ||
| 168 | |||
| 169 | * vc/vc-cvs.el (vc-cvs-stay-local): Doc fix. | ||
| 170 | * vc/vc-hooks.el (vc-stay-local): Doc fix. | ||
| 171 | |||
| 133 | 2013-06-09 Aidan Gauland <aidalgol@amuri.net> | 172 | 2013-06-09 Aidan Gauland <aidalgol@amuri.net> |
| 134 | 173 | ||
| 135 | * eshell/em-term.el (eshell-visual-command-p): Fix bug that caused | 174 | * eshell/em-term.el (eshell-visual-command-p): Fix bug that caused |
diff --git a/lisp/ibuf-ext.el b/lisp/ibuf-ext.el index 146ba61a517..de36c6c86ce 100644 --- a/lisp/ibuf-ext.el +++ b/lisp/ibuf-ext.el | |||
| @@ -1523,7 +1523,7 @@ You can then feed the file name(s) to other commands with \\[yank]." | |||
| 1523 | 1523 | ||
| 1524 | ;;;###autoload | 1524 | ;;;###autoload |
| 1525 | (defun ibuffer-mark-help-buffers () | 1525 | (defun ibuffer-mark-help-buffers () |
| 1526 | "Mark buffers like *Help*, *Apropos*, *Info*." | 1526 | "Mark buffers whose major mode is in variable `ibuffer-help-buffer-modes'." |
| 1527 | (interactive) | 1527 | (interactive) |
| 1528 | (ibuffer-mark-on-buffer | 1528 | (ibuffer-mark-on-buffer |
| 1529 | #'(lambda (buf) | 1529 | #'(lambda (buf) |
diff --git a/lisp/international/mule.el b/lisp/international/mule.el index dd0f3821728..4ce1a28c438 100644 --- a/lisp/international/mule.el +++ b/lisp/international/mule.el | |||
| @@ -1691,7 +1691,7 @@ ARC\\|ZIP\\|LZH\\|LHA\\|ZOO\\|[JEW]AR\\|XPI\\|RAR\\|7Z\\)\\'" | |||
| 1691 | ("\\.\\(gz\\|Z\\|bz\\|bz2\\|xz\\|gpg\\)\\'" . no-conversion) | 1691 | ("\\.\\(gz\\|Z\\|bz\\|bz2\\|xz\\|gpg\\)\\'" . no-conversion) |
| 1692 | ("\\.\\(jpe?g\\|png\\|gif\\|tiff?\\|p[bpgn]m\\)\\'" . no-conversion) | 1692 | ("\\.\\(jpe?g\\|png\\|gif\\|tiff?\\|p[bpgn]m\\)\\'" . no-conversion) |
| 1693 | ("\\.pdf\\'" . no-conversion) | 1693 | ("\\.pdf\\'" . no-conversion) |
| 1694 | ("/#[^/]+#\\'" . emacs-mule))) | 1694 | ("/#[^/]+#\\'" . utf-8-emacs-unix))) |
| 1695 | "Alist of filename patterns vs corresponding coding systems. | 1695 | "Alist of filename patterns vs corresponding coding systems. |
| 1696 | Each element looks like (REGEXP . CODING-SYSTEM). | 1696 | Each element looks like (REGEXP . CODING-SYSTEM). |
| 1697 | A file whose name matches REGEXP is decoded by CODING-SYSTEM on reading. | 1697 | A file whose name matches REGEXP is decoded by CODING-SYSTEM on reading. |
diff --git a/lisp/mail/reporter.el b/lisp/mail/reporter.el index cc20c5c06ea..8f6715018c4 100644 --- a/lisp/mail/reporter.el +++ b/lisp/mail/reporter.el | |||
| @@ -341,10 +341,10 @@ mail-sending package is used for editing and sending the message." | |||
| 341 | (mail-position-on-field "to") | 341 | (mail-position-on-field "to") |
| 342 | (insert address) | 342 | (insert address) |
| 343 | ;; insert problem summary if available | 343 | ;; insert problem summary if available |
| 344 | (if (and reporter-prompt-for-summary-p problem pkgname) | 344 | (when (and reporter-prompt-for-summary-p problem) |
| 345 | (progn | 345 | (mail-position-on-field "subject") |
| 346 | (mail-position-on-field "subject") | 346 | (if pkgname (insert pkgname "; ")) |
| 347 | (insert pkgname "; " problem))) | 347 | (insert problem)) |
| 348 | ;; move point to the body of the message | 348 | ;; move point to the body of the message |
| 349 | (mail-text) | 349 | (mail-text) |
| 350 | (forward-line 1) | 350 | (forward-line 1) |
diff --git a/lisp/textmodes/reftex-cite.el b/lisp/textmodes/reftex-cite.el index ca29709de2e..6c103294a06 100644 --- a/lisp/textmodes/reftex-cite.el +++ b/lisp/textmodes/reftex-cite.el | |||
| @@ -25,18 +25,16 @@ | |||
| 25 | ;;; Code: | 25 | ;;; Code: |
| 26 | 26 | ||
| 27 | (eval-when-compile (require 'cl)) | 27 | (eval-when-compile (require 'cl)) |
| 28 | (provide 'reftex-cite) | ||
| 29 | (require 'reftex) | ||
| 30 | ;;; | ||
| 31 | 28 | ||
| 32 | ;; Variables and constants | 29 | (require 'reftex) |
| 33 | 30 | ||
| 34 | ;; The history list of regular expressions used for citations | 31 | ;;; Variables and constants |
| 35 | (defvar reftex-cite-regexp-hist nil) | 32 | (defvar reftex-cite-regexp-hist nil |
| 33 | "The history list of regular expressions used for citations") | ||
| 36 | 34 | ||
| 37 | ;; Prompt and help string for citation selection | ||
| 38 | (defconst reftex-citation-prompt | 35 | (defconst reftex-citation-prompt |
| 39 | "Select: [n]ext [p]revious [r]estrict [ ]full_entry [q]uit RET [?]Help+more") | 36 | "Select: [n]ext [p]revious [r]estrict [ ]full_entry [q]uit RET [?]Help+more" |
| 37 | "Prompt and help string for citation selection") | ||
| 40 | 38 | ||
| 41 | (defconst reftex-citation-help | 39 | (defconst reftex-citation-help |
| 42 | " n / p Go to next/previous entry (Cursor motion works as well). | 40 | " n / p Go to next/previous entry (Cursor motion works as well). |
| @@ -51,8 +49,7 @@ | |||
| 51 | e / E Create BibTeX file with all (marked/unmarked) entries | 49 | e / E Create BibTeX file with all (marked/unmarked) entries |
| 52 | a / A Put all (marked) entries into one/many \\cite commands.") | 50 | a / A Put all (marked) entries into one/many \\cite commands.") |
| 53 | 51 | ||
| 54 | ;; Find bibtex files | 52 | ;;; Find bibtex files |
| 55 | |||
| 56 | (defmacro reftex-with-special-syntax-for-bib (&rest body) | 53 | (defmacro reftex-with-special-syntax-for-bib (&rest body) |
| 57 | `(let ((saved-syntax (syntax-table))) | 54 | `(let ((saved-syntax (syntax-table))) |
| 58 | (unwind-protect | 55 | (unwind-protect |
| @@ -62,8 +59,8 @@ | |||
| 62 | (set-syntax-table saved-syntax)))) | 59 | (set-syntax-table saved-syntax)))) |
| 63 | 60 | ||
| 64 | (defun reftex-default-bibliography () | 61 | (defun reftex-default-bibliography () |
| 65 | ;; Return the expanded value of `reftex-default-bibliography'. | 62 | "Return the expanded value of variable `reftex-default-bibliography'. |
| 66 | ;; The expanded value is cached. | 63 | The expanded value is cached." |
| 67 | (unless (eq (get 'reftex-default-bibliography :reftex-raw) | 64 | (unless (eq (get 'reftex-default-bibliography :reftex-raw) |
| 68 | reftex-default-bibliography) | 65 | reftex-default-bibliography) |
| 69 | (put 'reftex-default-bibliography :reftex-expanded | 66 | (put 'reftex-default-bibliography :reftex-expanded |
| @@ -74,9 +71,8 @@ | |||
| 74 | (get 'reftex-default-bibliography :reftex-expanded)) | 71 | (get 'reftex-default-bibliography :reftex-expanded)) |
| 75 | 72 | ||
| 76 | (defun reftex-bib-or-thebib () | 73 | (defun reftex-bib-or-thebib () |
| 77 | ;; Tests if BibTeX or \begin{thebibliography} should be used for the | 74 | "Test if BibTeX or \begin{thebibliography} should be used for the citation. |
| 78 | ;; citation | 75 | Find the bof of the current file" |
| 79 | ;; Find the bof of the current file | ||
| 80 | (let* ((docstruct (symbol-value reftex-docstruct-symbol)) | 76 | (let* ((docstruct (symbol-value reftex-docstruct-symbol)) |
| 81 | (rest (or (member (list 'bof (buffer-file-name)) docstruct) | 77 | (rest (or (member (list 'bof (buffer-file-name)) docstruct) |
| 82 | docstruct)) | 78 | docstruct)) |
| @@ -94,11 +90,11 @@ | |||
| 94 | (if thebib 'thebib nil)))) | 90 | (if thebib 'thebib nil)))) |
| 95 | 91 | ||
| 96 | (defun reftex-get-bibfile-list () | 92 | (defun reftex-get-bibfile-list () |
| 97 | ;; Return list of bibfiles for current document. | 93 | "Return list of bibfiles for current document. |
| 98 | ;; When using the chapterbib or bibunits package you should either | 94 | When using the chapterbib or bibunits package you should either |
| 99 | ;; use the same database files everywhere, or separate parts using | 95 | use the same database files everywhere, or separate parts using |
| 100 | ;; different databases into different files (included into the mater file). | 96 | different databases into different files (included into the mater file). |
| 101 | ;; Then this function will return the applicable database files. | 97 | Then this function will return the applicable database files." |
| 102 | 98 | ||
| 103 | ;; Ensure access to scanning info | 99 | ;; Ensure access to scanning info |
| 104 | (reftex-access-scan-info) | 100 | (reftex-access-scan-info) |
| @@ -115,16 +111,14 @@ | |||
| 115 | (cdr (assq 'bib (symbol-value reftex-docstruct-symbol))) | 111 | (cdr (assq 'bib (symbol-value reftex-docstruct-symbol))) |
| 116 | (error "\\bibliography statement missing or .bib files not found"))) | 112 | (error "\\bibliography statement missing or .bib files not found"))) |
| 117 | 113 | ||
| 118 | ;; Find a certain reference in any of the BibTeX files. | 114 | ;;; Find a certain reference in any of the BibTeX files. |
| 119 | |||
| 120 | (defun reftex-pop-to-bibtex-entry (key file-list &optional mark-to-kill | 115 | (defun reftex-pop-to-bibtex-entry (key file-list &optional mark-to-kill |
| 121 | highlight item return) | 116 | highlight item return) |
| 122 | ;; Find BibTeX KEY in any file in FILE-LIST in another window. | 117 | "Find BibTeX KEY in any file in FILE-LIST in another window. |
| 123 | ;; If MARK-TO-KILL is non-nil, mark new buffer to kill. | 118 | If MARK-TO-KILL is non-nil, mark new buffer to kill. |
| 124 | ;; If HIGHLIGHT is non-nil, highlight the match. | 119 | If HIGHLIGHT is non-nil, highlight the match. |
| 125 | ;; If ITEM in non-nil, search for bibitem instead of database entry. | 120 | If ITEM in non-nil, search for bibitem instead of database entry. |
| 126 | ;; If RETURN is non-nil, just return the entry and restore point. | 121 | If RETURN is non-nil, just return the entry and restore point." |
| 127 | |||
| 128 | (let* ((re | 122 | (let* ((re |
| 129 | (if item | 123 | (if item |
| 130 | (concat "\\\\bibitem[ \t]*\\(\\[[^]]*\\]\\)?[ \t]*{" | 124 | (concat "\\\\bibitem[ \t]*\\(\\[[^]]*\\]\\)?[ \t]*{" |
| @@ -178,12 +172,11 @@ | |||
| 178 | (progn (forward-list 1) (point))) | 172 | (progn (forward-list 1) (point))) |
| 179 | (error (min (point-max) (+ 300 (point))))))) | 173 | (error (min (point-max) (+ 300 (point))))))) |
| 180 | 174 | ||
| 181 | ;; Parse bibtex buffers | 175 | ;;; Parse bibtex buffers |
| 182 | |||
| 183 | (defun reftex-extract-bib-entries (buffers) | 176 | (defun reftex-extract-bib-entries (buffers) |
| 184 | ;; Extract bib entries which match regexps from BUFFERS. | 177 | "Extract bib entries which match regexps from BUFFERS. |
| 185 | ;; BUFFERS is a list of buffers or file names. | 178 | BUFFERS is a list of buffers or file names. |
| 186 | ;; Return list with entries." | 179 | Return list with entries." |
| 187 | (let* (re-list first-re rest-re | 180 | (let* (re-list first-re rest-re |
| 188 | (buffer-list (if (listp buffers) buffers (list buffers))) | 181 | (buffer-list (if (listp buffers) buffers (list buffers))) |
| 189 | found-list entry buffer1 buffer alist | 182 | found-list entry buffer1 buffer alist |
| @@ -309,6 +302,8 @@ | |||
| 309 | (t found-list)))) | 302 | (t found-list)))) |
| 310 | 303 | ||
| 311 | (defun reftex-bib-sort-author (e1 e2) | 304 | (defun reftex-bib-sort-author (e1 e2) |
| 305 | "Compare bib entries E1 and E2 by author. | ||
| 306 | The name of the first different author/editor is used." | ||
| 312 | (let ((al1 (reftex-get-bib-names "author" e1)) | 307 | (let ((al1 (reftex-get-bib-names "author" e1)) |
| 313 | (al2 (reftex-get-bib-names "author" e2))) | 308 | (al2 (reftex-get-bib-names "author" e2))) |
| 314 | (while (and al1 al2 (string= (car al1) (car al2))) | 309 | (while (and al1 al2 (string= (car al1) (car al2))) |
| @@ -320,15 +315,17 @@ | |||
| 320 | (not (stringp (car al1)))))) | 315 | (not (stringp (car al1)))))) |
| 321 | 316 | ||
| 322 | (defun reftex-bib-sort-year (e1 e2) | 317 | (defun reftex-bib-sort-year (e1 e2) |
| 318 | "Compare bib entries E1 and E2 by year in ascending order." | ||
| 323 | (< (string-to-number (or (cdr (assoc "year" e1)) "0")) | 319 | (< (string-to-number (or (cdr (assoc "year" e1)) "0")) |
| 324 | (string-to-number (or (cdr (assoc "year" e2)) "0")))) | 320 | (string-to-number (or (cdr (assoc "year" e2)) "0")))) |
| 325 | 321 | ||
| 326 | (defun reftex-bib-sort-year-reverse (e1 e2) | 322 | (defun reftex-bib-sort-year-reverse (e1 e2) |
| 323 | "Compare bib entries E1 and E2 by year in descending order." | ||
| 327 | (> (string-to-number (or (cdr (assoc "year" e1)) "0")) | 324 | (> (string-to-number (or (cdr (assoc "year" e1)) "0")) |
| 328 | (string-to-number (or (cdr (assoc "year" e2)) "0")))) | 325 | (string-to-number (or (cdr (assoc "year" e2)) "0")))) |
| 329 | 326 | ||
| 330 | (defun reftex-get-crossref-alist (entry) | 327 | (defun reftex-get-crossref-alist (entry) |
| 331 | ;; return the alist from a crossref entry | 328 | "Return the alist from a crossref ENTRY." |
| 332 | (let ((crkey (cdr (assoc "crossref" entry))) | 329 | (let ((crkey (cdr (assoc "crossref" entry))) |
| 333 | start) | 330 | start) |
| 334 | (save-excursion | 331 | (save-excursion |
| @@ -347,10 +344,9 @@ | |||
| 347 | 344 | ||
| 348 | ;; Parse the bibliography environment | 345 | ;; Parse the bibliography environment |
| 349 | (defun reftex-extract-bib-entries-from-thebibliography (files) | 346 | (defun reftex-extract-bib-entries-from-thebibliography (files) |
| 350 | ;; Extract bib-entries from the \begin{thebibliography} environment. | 347 | "Extract bib-entries from the \begin{thebibliography} environment. |
| 351 | ;; Parsing is not as good as for the BibTeX database stuff. | 348 | Parsing is not as good as for the BibTeX database stuff. |
| 352 | ;; The environment should be located in file FILE. | 349 | The environment should be located in FILES." |
| 353 | |||
| 354 | (let* (start end buf entries re re-list file default) | 350 | (let* (start end buf entries re re-list file default) |
| 355 | (unless files | 351 | (unless files |
| 356 | (error "Need file name to find thebibliography environment")) | 352 | (error "Need file name to find thebibliography environment")) |
| @@ -430,8 +426,8 @@ | |||
| 430 | entries)) | 426 | entries)) |
| 431 | 427 | ||
| 432 | (defun reftex-get-bibkey-default () | 428 | (defun reftex-get-bibkey-default () |
| 433 | ;; Return the word before the cursor. If the cursor is in a | 429 | "Return the word before the cursor. |
| 434 | ;; citation macro, return the word before the macro. | 430 | If the cursor is in a citation macro, return the word before the macro." |
| 435 | (let* ((macro (reftex-what-macro 1))) | 431 | (let* ((macro (reftex-what-macro 1))) |
| 436 | (save-excursion | 432 | (save-excursion |
| 437 | (if (and macro (string-match "cite" (car macro))) | 433 | (if (and macro (string-match "cite" (car macro))) |
| @@ -439,10 +435,10 @@ | |||
| 439 | (skip-chars-backward "^a-zA-Z0-9") | 435 | (skip-chars-backward "^a-zA-Z0-9") |
| 440 | (reftex-this-word)))) | 436 | (reftex-this-word)))) |
| 441 | 437 | ||
| 442 | ;; Parse and format individual entries | 438 | ;;; Parse and format individual entries |
| 443 | |||
| 444 | (defun reftex-get-bib-names (field entry) | 439 | (defun reftex-get-bib-names (field entry) |
| 445 | ;; Return a list with the author or editor names in ENTRY | 440 | "Return a list with the author or editor names in ENTRY. |
| 441 | If FIELD is empty try \"editor\" field." | ||
| 446 | (let ((names (reftex-get-bib-field field entry))) | 442 | (let ((names (reftex-get-bib-field field entry))) |
| 447 | (if (equal "" names) | 443 | (if (equal "" names) |
| 448 | (setq names (reftex-get-bib-field "editor" entry))) | 444 | (setq names (reftex-get-bib-field "editor" entry))) |
| @@ -457,7 +453,9 @@ | |||
| 457 | (split-string names "\n"))) | 453 | (split-string names "\n"))) |
| 458 | 454 | ||
| 459 | (defun reftex-parse-bibtex-entry (entry &optional from to raw) | 455 | (defun reftex-parse-bibtex-entry (entry &optional from to raw) |
| 460 | ; if RAW is non-nil, keep double quotes/curly braces delimiting fields | 456 | "Parse BibTeX ENTRY. |
| 457 | If ENTRY is nil then parse the entry in current buffer between FROM and TO. | ||
| 458 | If RAW is non-nil, keep double quotes/curly braces delimiting fields." | ||
| 461 | (let (alist key start field) | 459 | (let (alist key start field) |
| 462 | (save-excursion | 460 | (save-excursion |
| 463 | (save-restriction | 461 | (save-restriction |
| @@ -518,7 +516,8 @@ | |||
| 518 | alist)) | 516 | alist)) |
| 519 | 517 | ||
| 520 | (defun reftex-get-bib-field (fieldname entry &optional format) | 518 | (defun reftex-get-bib-field (fieldname entry &optional format) |
| 521 | ;; Extract the field FIELDNAME from an ENTRY | 519 | "Extract the field FIELDNAME from ENTRY. |
| 520 | If FORMAT is non-nil `format' entry accordingly." | ||
| 522 | (let ((cell (assoc fieldname entry))) | 521 | (let ((cell (assoc fieldname entry))) |
| 523 | (if cell | 522 | (if cell |
| 524 | (if format | 523 | (if format |
| @@ -527,7 +526,7 @@ | |||
| 527 | ""))) | 526 | ""))) |
| 528 | 527 | ||
| 529 | (defun reftex-format-bib-entry (entry) | 528 | (defun reftex-format-bib-entry (entry) |
| 530 | ;; Format a BibTeX ENTRY so that it is nice to look at | 529 | "Format a BibTeX ENTRY so that it is nice to look at." |
| 531 | (let* | 530 | (let* |
| 532 | ((auth-list (reftex-get-bib-names "author" entry)) | 531 | ((auth-list (reftex-get-bib-names "author" entry)) |
| 533 | (authors (mapconcat 'identity auth-list ", ")) | 532 | (authors (mapconcat 'identity auth-list ", ")) |
| @@ -570,7 +569,7 @@ | |||
| 570 | (concat key "\n " authors " " year " " extra "\n " title "\n\n"))) | 569 | (concat key "\n " authors " " year " " extra "\n " title "\n\n"))) |
| 571 | 570 | ||
| 572 | (defun reftex-parse-bibitem (item) | 571 | (defun reftex-parse-bibitem (item) |
| 573 | ;; Parse a \bibitem entry | 572 | "Parse a \bibitem entry in ITEM." |
| 574 | (let ((key "") (text "")) | 573 | (let ((key "") (text "")) |
| 575 | (when (string-match "\\`{\\([^}]+\\)}\\([^\000]*\\)" item) | 574 | (when (string-match "\\`{\\([^}]+\\)}\\([^\000]*\\)" item) |
| 576 | (setq key (match-string 1 item) | 575 | (setq key (match-string 1 item) |
| @@ -586,7 +585,7 @@ | |||
| 586 | (cons "&entry" (concat key " " text))))) | 585 | (cons "&entry" (concat key " " text))))) |
| 587 | 586 | ||
| 588 | (defun reftex-format-bibitem (item) | 587 | (defun reftex-format-bibitem (item) |
| 589 | ;; Format a \bibitem entry so that it is (relatively) nice to look at. | 588 | "Format a \bibitem entry in ITEM so that it is (relatively) nice to look at." |
| 590 | (let ((text (reftex-get-bib-field "&text" item)) | 589 | (let ((text (reftex-get-bib-field "&text" item)) |
| 591 | (key (reftex-get-bib-field "&key" item)) | 590 | (key (reftex-get-bib-field "&key" item)) |
| 592 | (lines nil)) | 591 | (lines nil)) |
| @@ -603,7 +602,7 @@ | |||
| 603 | (put-text-property 0 (length text) 'face reftex-bib-author-face text)) | 602 | (put-text-property 0 (length text) 'face reftex-bib-author-face text)) |
| 604 | (concat key "\n " text "\n\n"))) | 603 | (concat key "\n " text "\n\n"))) |
| 605 | 604 | ||
| 606 | ;; Make a citation | 605 | ;;; Make a citation |
| 607 | 606 | ||
| 608 | ;;;###autoload | 607 | ;;;###autoload |
| 609 | (defun reftex-citation (&optional no-insert format-key) | 608 | (defun reftex-citation (&optional no-insert format-key) |
| @@ -627,7 +626,6 @@ The regular expression uses an expanded syntax: && is interpreted as `and'. | |||
| 627 | Thus, `aaaa&&bbb' matches entries which contain both `aaaa' and `bbb'. | 626 | Thus, `aaaa&&bbb' matches entries which contain both `aaaa' and `bbb'. |
| 628 | While entering the regexp, completion on knows citation keys is possible. | 627 | While entering the regexp, completion on knows citation keys is possible. |
| 629 | `=' is a good regular expression to match all entries in all files." | 628 | `=' is a good regular expression to match all entries in all files." |
| 630 | |||
| 631 | (interactive) | 629 | (interactive) |
| 632 | 630 | ||
| 633 | ;; check for recursive edit | 631 | ;; check for recursive edit |
| @@ -645,8 +643,7 @@ While entering the regexp, completion on knows citation keys is possible. | |||
| 645 | (reftex-kill-temporary-buffers))) | 643 | (reftex-kill-temporary-buffers))) |
| 646 | 644 | ||
| 647 | (defun reftex-do-citation (&optional arg no-insert format-key) | 645 | (defun reftex-do-citation (&optional arg no-insert format-key) |
| 648 | ;; This really does the work of reftex-citation. | 646 | "This really does the work of `reftex-citation'." |
| 649 | |||
| 650 | (let* ((format (reftex-figure-out-cite-format arg no-insert format-key)) | 647 | (let* ((format (reftex-figure-out-cite-format arg no-insert format-key)) |
| 651 | (docstruct-symbol reftex-docstruct-symbol) | 648 | (docstruct-symbol reftex-docstruct-symbol) |
| 652 | (selected-entries (reftex-offer-bib-menu)) | 649 | (selected-entries (reftex-offer-bib-menu)) |
| @@ -743,8 +740,8 @@ While entering the regexp, completion on knows citation keys is possible. | |||
| 743 | (mapcar 'car selected-entries))) | 740 | (mapcar 'car selected-entries))) |
| 744 | 741 | ||
| 745 | (defun reftex-figure-out-cite-format (arg &optional no-insert format-key) | 742 | (defun reftex-figure-out-cite-format (arg &optional no-insert format-key) |
| 746 | ;; Check if there is already a cite command at point and change cite format | 743 | "Check if there is already a cite command at point and change cite format |
| 747 | ;; in order to only add another reference in the same cite command. | 744 | in order to only add another reference in the same cite command." |
| 748 | (let ((macro (car (reftex-what-macro 1))) | 745 | (let ((macro (car (reftex-what-macro 1))) |
| 749 | (cite-format-value (reftex-get-cite-format)) | 746 | (cite-format-value (reftex-get-cite-format)) |
| 750 | key format) | 747 | key format) |
| @@ -802,8 +799,7 @@ While entering the regexp, completion on knows citation keys is possible. | |||
| 802 | 799 | ||
| 803 | (defvar reftex-select-bib-map) | 800 | (defvar reftex-select-bib-map) |
| 804 | (defun reftex-offer-bib-menu () | 801 | (defun reftex-offer-bib-menu () |
| 805 | ;; Offer bib menu and return list of selected items | 802 | "Offer bib menu and return list of selected items." |
| 806 | |||
| 807 | (let ((bibtype (reftex-bib-or-thebib)) | 803 | (let ((bibtype (reftex-bib-or-thebib)) |
| 808 | found-list rtn key data selected-entries) | 804 | found-list rtn key data selected-entries) |
| 809 | (while | 805 | (while |
| @@ -917,7 +913,7 @@ While entering the regexp, completion on knows citation keys is possible. | |||
| 917 | selected-entries)) | 913 | selected-entries)) |
| 918 | 914 | ||
| 919 | (defun reftex-restrict-bib-matches (found-list) | 915 | (defun reftex-restrict-bib-matches (found-list) |
| 920 | ;; Limit FOUND-LIST with more regular expressions | 916 | "Limit FOUND-LIST with more regular expressions." |
| 921 | (let ((re-list (split-string (read-string | 917 | (let ((re-list (split-string (read-string |
| 922 | "RegExp [ && RegExp...]: " | 918 | "RegExp [ && RegExp...]: " |
| 923 | nil 'reftex-cite-regexp-hist) | 919 | nil 'reftex-cite-regexp-hist) |
| @@ -940,7 +936,7 @@ While entering the regexp, completion on knows citation keys is possible. | |||
| 940 | found-list))) | 936 | found-list))) |
| 941 | 937 | ||
| 942 | (defun reftex-extract-bib-file (all &optional marked complement) | 938 | (defun reftex-extract-bib-file (all &optional marked complement) |
| 943 | ;; Limit FOUND-LIST with more regular expressions | 939 | "Limit FOUND-LIST with more regular expressions." |
| 944 | (let ((file (read-file-name "File to create: "))) | 940 | (let ((file (read-file-name "File to create: "))) |
| 945 | (find-file-other-window file) | 941 | (find-file-other-window file) |
| 946 | (if (> (buffer-size) 0) | 942 | (if (> (buffer-size) 0) |
| @@ -963,7 +959,7 @@ While entering the regexp, completion on knows citation keys is possible. | |||
| 963 | (goto-char (point-min)))) | 959 | (goto-char (point-min)))) |
| 964 | 960 | ||
| 965 | (defun reftex-insert-bib-matches (list) | 961 | (defun reftex-insert-bib-matches (list) |
| 966 | ;; Insert the bib matches and number them correctly | 962 | "Insert the bib matches and number them correctly." |
| 967 | (let ((mouse-face | 963 | (let ((mouse-face |
| 968 | (if (memq reftex-highlight-selection '(mouse both)) | 964 | (if (memq reftex-highlight-selection '(mouse both)) |
| 969 | reftex-mouse-selected-face | 965 | reftex-mouse-selected-face |
| @@ -996,8 +992,7 @@ While entering the regexp, completion on knows citation keys is possible. | |||
| 996 | last))))) | 992 | last))))) |
| 997 | 993 | ||
| 998 | (defun reftex-format-citation (entry format) | 994 | (defun reftex-format-citation (entry format) |
| 999 | ;; Format a citation from the info in the BibTeX ENTRY | 995 | "Format a citation from the info in the BibTeX ENTRY according to FORMAT." |
| 1000 | |||
| 1001 | (unless (stringp format) (setq format "\\cite{%l}")) | 996 | (unless (stringp format) (setq format "\\cite{%l}")) |
| 1002 | 997 | ||
| 1003 | (if (and reftex-comment-citations | 998 | (if (and reftex-comment-citations |
| @@ -1064,7 +1059,7 @@ While entering the regexp, completion on knows citation keys is possible. | |||
| 1064 | format) | 1059 | format) |
| 1065 | 1060 | ||
| 1066 | (defun reftex-make-cite-echo-string (entry docstruct-symbol) | 1061 | (defun reftex-make-cite-echo-string (entry docstruct-symbol) |
| 1067 | ;; Format a bibtex entry for the echo area and cache the result. | 1062 | "Format a bibtex ENTRY for the echo area and cache the result." |
| 1068 | (let* ((key (reftex-get-bib-field "&key" entry)) | 1063 | (let* ((key (reftex-get-bib-field "&key" entry)) |
| 1069 | (string | 1064 | (string |
| 1070 | (let* ((reftex-cite-punctuation '(" " " & " " etal."))) | 1065 | (let* ((reftex-cite-punctuation '(" " " & " " etal."))) |
| @@ -1088,9 +1083,9 @@ While entering the regexp, completion on knows citation keys is possible. | |||
| 1088 | string)) | 1083 | string)) |
| 1089 | 1084 | ||
| 1090 | (defun reftex-bibtex-selection-callback (data ignore no-revisit) | 1085 | (defun reftex-bibtex-selection-callback (data ignore no-revisit) |
| 1091 | ;; Callback function to be called from the BibTeX selection, in | 1086 | "Callback function to be called from the BibTeX selection, in |
| 1092 | ;; order to display context. This function is relatively slow and not | 1087 | order to display context. This function is relatively slow and not |
| 1093 | ;; recommended for follow mode. It works OK for individual lookups. | 1088 | recommended for follow mode. It works OK for individual lookups." |
| 1094 | (let ((win (selected-window)) | 1089 | (let ((win (selected-window)) |
| 1095 | (key (reftex-get-bib-field "&key" data)) | 1090 | (key (reftex-get-bib-field "&key" data)) |
| 1096 | bibfile-list item bibtype) | 1091 | bibfile-list item bibtype) |
| @@ -1157,7 +1152,7 @@ While entering the regexp, completion on knows citation keys is possible. | |||
| 1157 | alist)))) | 1152 | alist)))) |
| 1158 | 1153 | ||
| 1159 | (defun reftex-create-bibtex-file (bibfile) | 1154 | (defun reftex-create-bibtex-file (bibfile) |
| 1160 | "Create a new BibTeX database file with all entries referenced in document. | 1155 | "Create a new BibTeX database BIBFILE with all entries referenced in document. |
| 1161 | The command prompts for a filename and writes the collected | 1156 | The command prompts for a filename and writes the collected |
| 1162 | entries to that file. Only entries referenced in the current | 1157 | entries to that file. Only entries referenced in the current |
| 1163 | document with any \\cite-like macros are used. The sequence in | 1158 | document with any \\cite-like macros are used. The sequence in |
| @@ -1247,5 +1242,5 @@ created files in the variables `reftex-create-bibtex-header' or | |||
| 1247 | (message "%d entries extracted and copied to new database" | 1242 | (message "%d entries extracted and copied to new database" |
| 1248 | (length entries)))) | 1243 | (length entries)))) |
| 1249 | 1244 | ||
| 1250 | 1245 | (provide 'reftex-cite) | |
| 1251 | ;;; reftex-cite.el ends here | 1246 | ;;; reftex-cite.el ends here |
diff --git a/lisp/textmodes/reftex-parse.el b/lisp/textmodes/reftex-parse.el index 3a64aad6a06..a99791e5427 100644 --- a/lisp/textmodes/reftex-parse.el +++ b/lisp/textmodes/reftex-parse.el | |||
| @@ -49,7 +49,8 @@ | |||
| 49 | (reftex-access-scan-info '(16))) | 49 | (reftex-access-scan-info '(16))) |
| 50 | 50 | ||
| 51 | (defun reftex-do-parse (rescan &optional file) | 51 | (defun reftex-do-parse (rescan &optional file) |
| 52 | "Do a document rescan. When allowed, do only a partial scan from FILE." | 52 | "Do a document rescan. |
| 53 | When allowed, do only a partial scan from FILE." | ||
| 53 | 54 | ||
| 54 | ;; Normalize the rescan argument | 55 | ;; Normalize the rescan argument |
| 55 | (setq rescan (cond ((eq rescan t) t) | 56 | (setq rescan (cond ((eq rescan t) t) |
| @@ -191,7 +192,7 @@ of master file." | |||
| 191 | (defvar index-tags) | 192 | (defvar index-tags) |
| 192 | 193 | ||
| 193 | (defun reftex-parse-from-file (file docstruct master-dir) | 194 | (defun reftex-parse-from-file (file docstruct master-dir) |
| 194 | ;; Scan the buffer for labels and save them in a list. | 195 | "Scan the buffer for labels and save them in a list." |
| 195 | (let ((regexp (reftex-everything-regexp)) | 196 | (let ((regexp (reftex-everything-regexp)) |
| 196 | (bound 0) | 197 | (bound 0) |
| 197 | file-found tmp include-file | 198 | file-found tmp include-file |
| @@ -350,8 +351,7 @@ of master file." | |||
| 350 | docstruct)) | 351 | docstruct)) |
| 351 | 352 | ||
| 352 | (defun reftex-locate-bibliography-files (master-dir &optional files) | 353 | (defun reftex-locate-bibliography-files (master-dir &optional files) |
| 353 | ;; Scan buffer for bibliography macro and return file list. | 354 | "Scan buffer for bibliography macro and return file list." |
| 354 | |||
| 355 | (unless files | 355 | (unless files |
| 356 | (save-excursion | 356 | (save-excursion |
| 357 | (goto-char (point-min)) | 357 | (goto-char (point-min)) |
| @@ -379,10 +379,10 @@ of master file." | |||
| 379 | (delq nil files))) | 379 | (delq nil files))) |
| 380 | 380 | ||
| 381 | (defun reftex-replace-label-list-segment (old insert &optional entirely) | 381 | (defun reftex-replace-label-list-segment (old insert &optional entirely) |
| 382 | ;; Replace the segment in OLD which corresponds to INSERT. | 382 | "Replace the segment in OLD which corresponds to INSERT. |
| 383 | ;; Works with side effects, directly changes old. | 383 | Works with side effects, directly changes old. |
| 384 | ;; If entirely is t, just return INSERT. | 384 | If ENTIRELY is t, just return INSERT. |
| 385 | ;; This function also makes sure the old toc markers do not point anywhere. | 385 | This function also makes sure the old toc markers do not point anywhere." |
| 386 | 386 | ||
| 387 | (cond | 387 | (cond |
| 388 | (entirely | 388 | (entirely |
| @@ -404,8 +404,8 @@ of master file." | |||
| 404 | new)))) | 404 | new)))) |
| 405 | 405 | ||
| 406 | (defun reftex-section-info (file) | 406 | (defun reftex-section-info (file) |
| 407 | ;; Return a section entry for the current match. | 407 | "Return a section entry for the current match. |
| 408 | ;; Careful: This function expects the match-data to be still in place! | 408 | Careful: This function expects the match-data to be still in place!" |
| 409 | (let* ((marker (set-marker (make-marker) (1- (match-beginning 3)))) | 409 | (let* ((marker (set-marker (make-marker) (1- (match-beginning 3)))) |
| 410 | (macro (reftex-match-string 3)) | 410 | (macro (reftex-match-string 3)) |
| 411 | (prefix (save-match-data | 411 | (prefix (save-match-data |
| @@ -440,9 +440,9 @@ of master file." | |||
| 440 | literal (marker-position marker)))) | 440 | literal (marker-position marker)))) |
| 441 | 441 | ||
| 442 | (defun reftex-ensure-index-support (&optional abort) | 442 | (defun reftex-ensure-index-support (&optional abort) |
| 443 | ;; When index support is turned off, ask to turn it on and | 443 | "When index support is turned off, ask to turn it on and |
| 444 | ;; set the current prefix argument so that `reftex-access-scan-info' | 444 | set the current prefix argument so that `reftex-access-scan-info' |
| 445 | ;; will rescan the entire document. | 445 | will rescan the entire document." |
| 446 | (cond | 446 | (cond |
| 447 | (reftex-support-index t) | 447 | (reftex-support-index t) |
| 448 | ((y-or-n-p "Turn on index support and rescan entire document? ") | 448 | ((y-or-n-p "Turn on index support and rescan entire document? ") |
| @@ -460,8 +460,8 @@ of master file." | |||
| 460 | 460 | ||
| 461 | (defvar test-dummy) | 461 | (defvar test-dummy) |
| 462 | (defun reftex-index-info (file) | 462 | (defun reftex-index-info (file) |
| 463 | ;; Return an index entry for the current match. | 463 | "Return an index entry for the current match. |
| 464 | ;; Careful: This function expects the match-data to be still in place! | 464 | Careful: This function expects the match-data to be still in place!" |
| 465 | (catch 'exit | 465 | (catch 'exit |
| 466 | (let* ((macro (reftex-match-string 10)) | 466 | (let* ((macro (reftex-match-string 10)) |
| 467 | (bom (match-beginning 10)) | 467 | (bom (match-beginning 10)) |
| @@ -508,7 +508,7 @@ of master file." | |||
| 508 | (list 'index index-tag context file bom arg key showkey sortkey key-end)))) | 508 | (list 'index index-tag context file bom arg key showkey sortkey key-end)))) |
| 509 | 509 | ||
| 510 | (defun reftex-short-context (env parse &optional bound derive) | 510 | (defun reftex-short-context (env parse &optional bound derive) |
| 511 | ;; Get about one line of useful context for the label definition at point. | 511 | "Get about one line of useful context for the label definition at point." |
| 512 | 512 | ||
| 513 | (if (consp parse) | 513 | (if (consp parse) |
| 514 | (setq parse (if derive (cdr parse) (car parse)))) | 514 | (setq parse (if derive (cdr parse) (car parse)))) |
| @@ -568,9 +568,9 @@ of master file." | |||
| 568 | "INVALID VALUE OF PARSE")))) | 568 | "INVALID VALUE OF PARSE")))) |
| 569 | 569 | ||
| 570 | (defun reftex-where-am-I () | 570 | (defun reftex-where-am-I () |
| 571 | ;; Return the docstruct entry above point. Actually returns a cons | 571 | "Return the docstruct entry above point. |
| 572 | ;; cell in which the cdr is a flag indicating if the information is | 572 | Actually returns a cons cell in which the cdr is a flag indicating |
| 573 | ;; exact (t) or approximate (nil). | 573 | if the information is exact (t) or approximate (nil)." |
| 574 | 574 | ||
| 575 | (let ((docstruct (symbol-value reftex-docstruct-symbol)) | 575 | (let ((docstruct (symbol-value reftex-docstruct-symbol)) |
| 576 | (cnt 0) rtn rtn-if-no-other | 576 | (cnt 0) rtn rtn-if-no-other |
| @@ -748,10 +748,10 @@ of master file." | |||
| 748 | ) | 748 | ) |
| 749 | 749 | ||
| 750 | (defsubst reftex-move-to-previous-arg (&optional bound) | 750 | (defsubst reftex-move-to-previous-arg (&optional bound) |
| 751 | ;; Assuming that we are in front of a macro argument, | 751 | "Assuming that we are in front of a macro argument, |
| 752 | ;; move backward to the closing parenthesis of the previous argument. | 752 | move backward to the closing parenthesis of the previous argument. |
| 753 | ;; This function understands the splitting of macros over several lines | 753 | This function understands the splitting of macros over several lines |
| 754 | ;; in TeX. | 754 | in TeX." |
| 755 | (cond | 755 | (cond |
| 756 | ;; Just to be quick: | 756 | ;; Just to be quick: |
| 757 | ((memq (preceding-char) '(?\] ?\}))) | 757 | ((memq (preceding-char) '(?\] ?\}))) |
| @@ -764,28 +764,27 @@ of master file." | |||
| 764 | (t nil))) | 764 | (t nil))) |
| 765 | 765 | ||
| 766 | (defun reftex-what-macro-safe (which &optional bound) | 766 | (defun reftex-what-macro-safe (which &optional bound) |
| 767 | ;; reftex-what-macro with special syntax table. | 767 | "Call `reftex-what-macro' with special syntax table." |
| 768 | (reftex-with-special-syntax | 768 | (reftex-with-special-syntax |
| 769 | (reftex-what-macro which bound))) | 769 | (reftex-what-macro which bound))) |
| 770 | 770 | ||
| 771 | (defun reftex-what-macro (which &optional bound) | 771 | (defun reftex-what-macro (which &optional bound) |
| 772 | ;; Find out if point is within the arguments of any TeX-macro. | 772 | "Find out if point is within the arguments of any TeX-macro. |
| 773 | ;; The return value is either ("\\macro" . (point)) or a list of them. | 773 | The return value is either (\"\\macro\" . (point)) or a list of them. |
| 774 | 774 | ||
| 775 | ;; If WHICH is nil, immediately return nil. | 775 | If WHICH is nil, immediately return nil. |
| 776 | ;; If WHICH is 1, return innermost enclosing macro. | 776 | If WHICH is 1, return innermost enclosing macro. |
| 777 | ;; If WHICH is t, return list of all macros enclosing point. | 777 | If WHICH is t, return list of all macros enclosing point. |
| 778 | ;; If WHICH is a list of macros, look only for those macros and return the | 778 | If WHICH is a list of macros, look only for those macros and return the |
| 779 | ;; name of the first macro in this list found to enclose point. | 779 | name of the first macro in this list found to enclose point. |
| 780 | ;; If the optional BOUND is an integer, bound backwards directed | 780 | If the optional BOUND is an integer, bound backwards directed |
| 781 | ;; searches to this point. If it is nil, limit to nearest \section - | 781 | searches to this point. If it is nil, limit to nearest \\section - |
| 782 | ;; like statement. | 782 | like statement. |
| 783 | 783 | ||
| 784 | ;; This function is pretty stable, but can be fooled if the text contains | 784 | This function is pretty stable, but can be fooled if the text contains |
| 785 | ;; things like \macro{aa}{bb} where \macro is defined to take only one | 785 | things like \\macro{aa}{bb} where \\macro is defined to take only one |
| 786 | ;; argument. As RefTeX cannot know this, the string "bb" would still be | 786 | argument. As RefTeX cannot know this, the string \"bb\" would still be |
| 787 | ;; considered an argument of macro \macro. | 787 | considered an argument of macro \\macro." |
| 788 | |||
| 789 | (unless reftex-section-regexp (reftex-compile-variables)) | 788 | (unless reftex-section-regexp (reftex-compile-variables)) |
| 790 | (catch 'exit | 789 | (catch 'exit |
| 791 | (if (null which) (throw 'exit nil)) | 790 | (if (null which) (throw 'exit nil)) |
| @@ -832,20 +831,19 @@ of master file." | |||
| 832 | (nreverse cmd-list))))) | 831 | (nreverse cmd-list))))) |
| 833 | 832 | ||
| 834 | (defun reftex-what-environment (which &optional bound) | 833 | (defun reftex-what-environment (which &optional bound) |
| 835 | ;; Find out if point is inside a LaTeX environment. | 834 | "Find out if point is inside a LaTeX environment. |
| 836 | ;; The return value is (e.g.) either ("equation" . (point)) or a list of | 835 | The return value is (e.g.) either (\"equation\" . (point)) or a list of |
| 837 | ;; them. | 836 | them. |
| 838 | 837 | ||
| 839 | ;; If WHICH is nil, immediately return nil. | 838 | If WHICH is nil, immediately return nil. |
| 840 | ;; If WHICH is 1, return innermost enclosing environment. | 839 | If WHICH is 1, return innermost enclosing environment. |
| 841 | ;; If WHICH is t, return list of all environments enclosing point. | 840 | If WHICH is t, return list of all environments enclosing point. |
| 842 | ;; If WHICH is a list of environments, look only for those environments and | 841 | If WHICH is a list of environments, look only for those environments and |
| 843 | ;; return the name of the first environment in this list found to enclose | 842 | return the name of the first environment in this list found to enclose |
| 844 | ;; point. | 843 | point. |
| 845 | 844 | ||
| 846 | ;; If the optional BOUND is an integer, bound backwards directed searches to | 845 | If the optional BOUND is an integer, bound backwards directed searches to |
| 847 | ;; this point. If it is nil, limit to nearest \section - like statement. | 846 | this point. If it is nil, limit to nearest \\section - like statement." |
| 848 | |||
| 849 | (unless reftex-section-regexp (reftex-compile-variables)) | 847 | (unless reftex-section-regexp (reftex-compile-variables)) |
| 850 | (catch 'exit | 848 | (catch 'exit |
| 851 | (save-excursion | 849 | (save-excursion |
| @@ -870,18 +868,17 @@ of master file." | |||
| 870 | (nreverse env-list))))) | 868 | (nreverse env-list))))) |
| 871 | 869 | ||
| 872 | (defun reftex-what-special-env (which &optional bound) | 870 | (defun reftex-what-special-env (which &optional bound) |
| 873 | ;; Run the special environment parsers and return the matches. | 871 | "Run the special environment parsers and return the matches. |
| 874 | ;; | 872 | |
| 875 | ;; The return value is (e.g.) either ("my-parser-function" . (point)) | 873 | The return value is (e.g.) either (\"my-parser-function\" . (point)) |
| 876 | ;; or a list of them. | 874 | or a list of them. |
| 877 | |||
| 878 | ;; If WHICH is nil, immediately return nil. | ||
| 879 | ;; If WHICH is 1, return innermost enclosing environment. | ||
| 880 | ;; If WHICH is t, return list of all environments enclosing point. | ||
| 881 | ;; If WHICH is a list of environments, look only for those environments and | ||
| 882 | ;; return the name of the first environment in this list found to enclose | ||
| 883 | ;; point. | ||
| 884 | 875 | ||
| 876 | If WHICH is nil, immediately return nil. | ||
| 877 | If WHICH is 1, return innermost enclosing environment. | ||
| 878 | If WHICH is t, return list of all environments enclosing point. | ||
| 879 | If WHICH is a list of environments, look only for those environments and | ||
| 880 | return the name of the first environment in this list found to enclose | ||
| 881 | point." | ||
| 885 | (unless reftex-section-regexp (reftex-compile-variables)) | 882 | (unless reftex-section-regexp (reftex-compile-variables)) |
| 886 | (catch 'exit | 883 | (catch 'exit |
| 887 | (save-excursion | 884 | (save-excursion |
| @@ -911,10 +908,10 @@ of master file." | |||
| 911 | (car specials)))))) | 908 | (car specials)))))) |
| 912 | 909 | ||
| 913 | (defsubst reftex-move-to-next-arg (&optional ignore) | 910 | (defsubst reftex-move-to-next-arg (&optional ignore) |
| 914 | ;; Assuming that we are at the end of a macro name or a macro argument, | 911 | "Assuming that we are at the end of a macro name or a macro argument, |
| 915 | ;; move forward to the opening parenthesis of the next argument. | 912 | move forward to the opening parenthesis of the next argument. |
| 916 | ;; This function understands the splitting of macros over several lines | 913 | This function understands the splitting of macros over several lines |
| 917 | ;; in TeX. | 914 | in TeX." |
| 918 | (cond | 915 | (cond |
| 919 | ;; Just to be quick: | 916 | ;; Just to be quick: |
| 920 | ((memq (following-char) '(?\[ ?\{))) | 917 | ((memq (following-char) '(?\[ ?\{))) |
| @@ -930,8 +927,8 @@ of master file." | |||
| 930 | (reftex-nth-arg (nth 5 entry) (nth 6 entry)))) | 927 | (reftex-nth-arg (nth 5 entry) (nth 6 entry)))) |
| 931 | 928 | ||
| 932 | (defun reftex-nth-arg (n &optional opt-args) | 929 | (defun reftex-nth-arg (n &optional opt-args) |
| 933 | ;; Return the nth following {} or [] parentheses content. | 930 | "Return the Nth following {} or [] parentheses content. |
| 934 | ;; OPT-ARGS is a list of argument numbers which are optional. | 931 | OPT-ARGS is a list of argument numbers which are optional." |
| 935 | 932 | ||
| 936 | ;; If we are sitting at a macro start, skip to end of macro name. | 933 | ;; If we are sitting at a macro start, skip to end of macro name. |
| 937 | (and (eq (following-char) ?\\) (skip-chars-forward "a-zA-Z*\\\\")) | 934 | (and (eq (following-char) ?\\) (skip-chars-forward "a-zA-Z*\\\\")) |
| @@ -974,8 +971,8 @@ of master file." | |||
| 974 | (error nil))) | 971 | (error nil))) |
| 975 | 972 | ||
| 976 | (defun reftex-context-substring (&optional to-end) | 973 | (defun reftex-context-substring (&optional to-end) |
| 977 | ;; Return up to 150 chars from point | 974 | "Return up to 150 chars from point. |
| 978 | ;; When point is just after a { or [, limit string to matching parenthesis | 975 | When point is just after a { or [, limit string to matching parenthesis" |
| 979 | (cond | 976 | (cond |
| 980 | (to-end | 977 | (to-end |
| 981 | ;; Environment - find next \end | 978 | ;; Environment - find next \end |
| @@ -1007,8 +1004,7 @@ of master file." | |||
| 1007 | (defvar reftex-section-numbers (make-vector reftex-max-section-depth 0)) | 1004 | (defvar reftex-section-numbers (make-vector reftex-max-section-depth 0)) |
| 1008 | 1005 | ||
| 1009 | (defun reftex-init-section-numbers (&optional toc-entry appendix) | 1006 | (defun reftex-init-section-numbers (&optional toc-entry appendix) |
| 1010 | ;; Initialize the section numbers with zeros or with what is found | 1007 | "Initialize the section numbers with zeros or with what is found in the TOC-ENTRY." |
| 1011 | ;; in the toc entry. | ||
| 1012 | (let* ((level (or (nth 5 toc-entry) -1)) | 1008 | (let* ((level (or (nth 5 toc-entry) -1)) |
| 1013 | (numbers (nreverse (split-string (or (nth 6 toc-entry) "") "\\."))) | 1009 | (numbers (nreverse (split-string (or (nth 6 toc-entry) "") "\\."))) |
| 1014 | (depth (1- (length reftex-section-numbers))) | 1010 | (depth (1- (length reftex-section-numbers))) |
| @@ -1026,8 +1022,8 @@ of master file." | |||
| 1026 | (put 'reftex-section-numbers 'appendix appendix)) | 1022 | (put 'reftex-section-numbers 'appendix appendix)) |
| 1027 | 1023 | ||
| 1028 | (defun reftex-section-number (&optional level star) | 1024 | (defun reftex-section-number (&optional level star) |
| 1029 | ;; Return a string with the current section number. | 1025 | "Return a string with the current section number. |
| 1030 | ;; When LEVEL is non-nil, increase section numbers on that level. | 1026 | When LEVEL is non-nil, increase section numbers on that level." |
| 1031 | (let* ((depth (1- (length reftex-section-numbers))) idx n (string "") | 1027 | (let* ((depth (1- (length reftex-section-numbers))) idx n (string "") |
| 1032 | (appendix (get 'reftex-section-numbers 'appendix)) | 1028 | (appendix (get 'reftex-section-numbers 'appendix)) |
| 1033 | (partspecial (and (not reftex-part-resets-chapter) | 1029 | (partspecial (and (not reftex-part-resets-chapter) |
| @@ -1073,7 +1069,7 @@ of master file." | |||
| 1073 | string)))) | 1069 | string)))) |
| 1074 | 1070 | ||
| 1075 | (defun reftex-roman-number (n) | 1071 | (defun reftex-roman-number (n) |
| 1076 | ;; Return as a string the roman number equal to N. | 1072 | "Return as a string the roman number equal to N." |
| 1077 | (let ((nrest n) | 1073 | (let ((nrest n) |
| 1078 | (string "") | 1074 | (string "") |
| 1079 | (list '((1000 . "M") ( 900 . "CM") ( 500 . "D") ( 400 . "CD") | 1075 | (list '((1000 . "M") ( 900 . "CM") ( 500 . "D") ( 400 . "CD") |
diff --git a/lisp/vc/vc-cvs.el b/lisp/vc/vc-cvs.el index eee896056c6..17b278d1ce4 100644 --- a/lisp/vc/vc-cvs.el +++ b/lisp/vc/vc-cvs.el | |||
| @@ -115,7 +115,7 @@ This is only meaningful if you don't use the implicit checkout model | |||
| 115 | This avoids slow queries over the network and instead uses heuristics | 115 | This avoids slow queries over the network and instead uses heuristics |
| 116 | and past information to determine the current status of a file. | 116 | and past information to determine the current status of a file. |
| 117 | 117 | ||
| 118 | If value is the symbol `only-file' `vc-dir' will connect to the | 118 | If value is the symbol `only-file', `vc-dir' will connect to the |
| 119 | server, but heuristics will be used to determine the status for | 119 | server, but heuristics will be used to determine the status for |
| 120 | all other VC operations. | 120 | all other VC operations. |
| 121 | 121 | ||
diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el index 5c8a4515b7e..284481ee524 100644 --- a/lisp/vc/vc-hooks.el +++ b/lisp/vc/vc-hooks.el | |||
| @@ -128,7 +128,7 @@ See also variable `vc-consult-headers'." | |||
| 128 | This avoids slow queries over the network and instead uses heuristics | 128 | This avoids slow queries over the network and instead uses heuristics |
| 129 | and past information to determine the current status of a file. | 129 | and past information to determine the current status of a file. |
| 130 | 130 | ||
| 131 | If value is the symbol `only-file' `vc-dir' will connect to the | 131 | If value is the symbol `only-file', `vc-dir' will connect to the |
| 132 | server, but heuristics will be used to determine the status for | 132 | server, but heuristics will be used to determine the status for |
| 133 | all other VC operations. | 133 | all other VC operations. |
| 134 | 134 | ||
diff --git a/test/ChangeLog b/test/ChangeLog index 98fb2e3da1f..2e8364e1d2a 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2013-06-12 Rüdiger Sonderfeld <ruediger@c-plusplus.de> | ||
| 2 | |||
| 3 | * automated/reftex-tests.el (reftex-parse-from-file-test): Fix | ||
| 4 | test. | ||
| 5 | |||
| 6 | 2013-06-12 Rüdiger Sonderfeld <ruediger@c-plusplus.de> | ||
| 7 | |||
| 8 | * automated/reftex-tests.el: New test suite for reftex. | ||
| 9 | |||
| 1 | 2013-05-31 Dmitry Gutov <dgutov@yandex.ru> | 10 | 2013-05-31 Dmitry Gutov <dgutov@yandex.ru> |
| 2 | 11 | ||
| 3 | * automated/ruby-mode-tests.el: New tests, for percent literals | 12 | * automated/ruby-mode-tests.el: New tests, for percent literals |
diff --git a/test/automated/reftex-tests.el b/test/automated/reftex-tests.el new file mode 100644 index 00000000000..de7f36d825a --- /dev/null +++ b/test/automated/reftex-tests.el | |||
| @@ -0,0 +1,201 @@ | |||
| 1 | ;;; reftex-tests.el --- Test suite for reftex. -*- lexical-binding: t -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2013 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Rüdiger Sonderfeld <ruediger@c-plusplus.de> | ||
| 6 | ;; Keywords: internal | ||
| 7 | ;; Human-Keywords: internal | ||
| 8 | |||
| 9 | ;; This file is part of GNU Emacs. | ||
| 10 | |||
| 11 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 12 | ;; it under the terms of the GNU General Public License as published by | ||
| 13 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 14 | ;; (at your option) any later version. | ||
| 15 | |||
| 16 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 19 | ;; GNU General Public License for more details. | ||
| 20 | |||
| 21 | ;; You should have received a copy of the GNU General Public License | ||
| 22 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | ||
| 23 | |||
| 24 | ;;; Code: | ||
| 25 | |||
| 26 | (require 'ert) | ||
| 27 | |||
| 28 | ;;; reftex | ||
| 29 | (require 'reftex) | ||
| 30 | |||
| 31 | ;;; reftex-parse | ||
| 32 | (require 'reftex-parse) | ||
| 33 | |||
| 34 | (ert-deftest reftex-locate-bibliography-files () | ||
| 35 | "Test `reftex-locate-bibliography-files'." | ||
| 36 | (let ((temp-dir (make-temp-file "reftex-bib" 'dir)) | ||
| 37 | (files '("ref1.bib" "ref2.bib")) | ||
| 38 | (test '(("\\addbibresource{ref1.bib}\n" . ("ref1.bib")) | ||
| 39 | ("\\\\addbibresource[label=x]{ref2.bib}\\n" . ("ref2.bib")) | ||
| 40 | ("\\begin{document}\n\\bibliographystyle{plain}\n | ||
| 41 | \\bibliography{ref1,ref2}\n\\end{document}" . ("ref1.bib" "ref2.bib")))) | ||
| 42 | (reftex-bibliography-commands | ||
| 43 | ;; Default value: See reftex-vars.el `reftex-bibliography-commands' | ||
| 44 | '("bibliography" "nobibliography" "setupbibtex\\[.*?database=" | ||
| 45 | "addbibresource"))) | ||
| 46 | (with-temp-buffer | ||
| 47 | (insert "test\n") | ||
| 48 | (mapc | ||
| 49 | (lambda (file) | ||
| 50 | (write-region (point-min) (point-max) (expand-file-name file | ||
| 51 | temp-dir))) | ||
| 52 | files)) | ||
| 53 | (mapc | ||
| 54 | (lambda (data) | ||
| 55 | (with-temp-buffer | ||
| 56 | (insert (car data)) | ||
| 57 | (let ((res (mapcar #'file-name-nondirectory | ||
| 58 | (reftex-locate-bibliography-files temp-dir)))) | ||
| 59 | (should (equal res (cdr data)))))) | ||
| 60 | test) | ||
| 61 | (delete-directory temp-dir 'recursive))) | ||
| 62 | |||
| 63 | (ert-deftest reftex-what-environment-test () | ||
| 64 | "Test `reftex-what-environment'." | ||
| 65 | (with-temp-buffer | ||
| 66 | (insert "\\begin{equation}\n x=y^2\n") | ||
| 67 | (let ((pt (point)) | ||
| 68 | pt2) | ||
| 69 | (insert "\\end{equation}\n") | ||
| 70 | (goto-char pt) | ||
| 71 | |||
| 72 | (should (equal (reftex-what-environment 1) '("equation" . 1))) | ||
| 73 | (should (equal (reftex-what-environment t) '(("equation" . 1)))) | ||
| 74 | |||
| 75 | (insert "\\begin{something}\nxxx") | ||
| 76 | (setq pt2 (point)) | ||
| 77 | (insert "\\end{something}") | ||
| 78 | (goto-char pt2) | ||
| 79 | (should (equal (reftex-what-environment 1) `("something" . ,pt))) | ||
| 80 | (should (equal (reftex-what-environment t) `(("something" . ,pt) | ||
| 81 | ("equation" . 1)))) | ||
| 82 | (should (equal (reftex-what-environment t pt) `(("something" . ,pt)))) | ||
| 83 | (should (equal (reftex-what-environment '("equation")) | ||
| 84 | '("equation" . 1)))))) | ||
| 85 | |||
| 86 | (ert-deftest reftex-roman-number-test () | ||
| 87 | "Test `reftex-roman-number'." | ||
| 88 | (let ((hindu-arabic '(1 2 4 9 14 1050)) | ||
| 89 | (roman '("I" "II" "IV" "IX" "XIV" "ML"))) | ||
| 90 | (while (and hindu-arabic roman) | ||
| 91 | (should (string= (reftex-roman-number (car hindu-arabic)) | ||
| 92 | (car roman))) | ||
| 93 | (pop roman) | ||
| 94 | (pop hindu-arabic)))) | ||
| 95 | |||
| 96 | (ert-deftest reftex-parse-from-file-test () | ||
| 97 | "Test `reftex-parse-from-file'." | ||
| 98 | (let* ((temp-dir (make-temp-file "reftex-parse" 'dir)) | ||
| 99 | (tex-file (expand-file-name "test.tex" temp-dir)) | ||
| 100 | (bib-file (expand-file-name "ref.bib" temp-dir))) | ||
| 101 | (with-temp-buffer | ||
| 102 | (insert | ||
| 103 | "\\begin{document} | ||
| 104 | \\section{test}\\label{sec:test} | ||
| 105 | \\subsection{subtest} | ||
| 106 | |||
| 107 | \\begin{align*}\\label{eq:foo} | ||
| 108 | x &= y^2 | ||
| 109 | \\end{align*} | ||
| 110 | |||
| 111 | \\bibliographystyle{plain} | ||
| 112 | \\bibliography{ref} | ||
| 113 | \\end{document}") | ||
| 114 | (write-region (point-min) (point-max) tex-file)) | ||
| 115 | (with-temp-buffer | ||
| 116 | (insert "test\n") | ||
| 117 | (write-region (point-min) (point-max) bib-file)) | ||
| 118 | (reftex-ensure-compiled-variables) | ||
| 119 | (let ((parsed (reftex-parse-from-file tex-file nil temp-dir))) | ||
| 120 | (should (equal (car parsed) `(eof ,tex-file))) | ||
| 121 | (pop parsed) | ||
| 122 | (while parsed | ||
| 123 | (let ((entry (pop parsed))) | ||
| 124 | (cond | ||
| 125 | ((eq (car entry) 'bib) | ||
| 126 | (should (string= (cadr entry) bib-file))) | ||
| 127 | ((eq (car entry) 'toc)) ;; ... | ||
| 128 | ((string= (car entry) "eq:foo")) | ||
| 129 | ((string= (car entry) "sec:test")) | ||
| 130 | ((eq (car entry) 'bof) | ||
| 131 | (should (string= (cadr entry) tex-file)) | ||
| 132 | (should (null parsed))) | ||
| 133 | (t (should-not t))))) | ||
| 134 | (delete-directory temp-dir 'recursive)))) | ||
| 135 | |||
| 136 | ;;; reftex-cite | ||
| 137 | (require 'reftex-cite) | ||
| 138 | |||
| 139 | (ert-deftest reftex-parse-bibtex-entry-test () | ||
| 140 | "Test `reftex-parse-bibtex-entry'." | ||
| 141 | (let ((entry "@Book{Stallman12, | ||
| 142 | author = {Richard Stallman\net al.}, | ||
| 143 | title = {The Emacs Editor}, | ||
| 144 | publisher = {GNU Press}, | ||
| 145 | year = 2012, | ||
| 146 | edition = {17th}, | ||
| 147 | note = {Updated for Emacs Version 24.2} | ||
| 148 | }") | ||
| 149 | (check (function | ||
| 150 | (lambda (parsed) | ||
| 151 | (should (string= (reftex-get-bib-field "&key" parsed) | ||
| 152 | "Stallman12")) | ||
| 153 | (should (string= (reftex-get-bib-field "&type" parsed) | ||
| 154 | "book")) | ||
| 155 | (should (string= (reftex-get-bib-field "author" parsed) | ||
| 156 | "Richard Stallman et al.")) | ||
| 157 | (should (string= (reftex-get-bib-field "title" parsed) | ||
| 158 | "The Emacs Editor")) | ||
| 159 | (should (string= (reftex-get-bib-field "publisher" parsed) | ||
| 160 | "GNU Press")) | ||
| 161 | (should (string= (reftex-get-bib-field "year" parsed) | ||
| 162 | "2012")) | ||
| 163 | (should (string= (reftex-get-bib-field "edition" parsed) | ||
| 164 | "17th")) | ||
| 165 | (should (string= (reftex-get-bib-field "note" parsed) | ||
| 166 | "Updated for Emacs Version 24.2")))))) | ||
| 167 | (funcall check (reftex-parse-bibtex-entry entry)) | ||
| 168 | (with-temp-buffer | ||
| 169 | (insert entry) | ||
| 170 | (funcall check (reftex-parse-bibtex-entry nil (point-min) | ||
| 171 | (point-max)))))) | ||
| 172 | |||
| 173 | (ert-deftest reftex-get-bib-names-test () | ||
| 174 | "Test `reftex-get-bib-names'." | ||
| 175 | (let ((entry (reftex-parse-bibtex-entry "@article{Foo123, | ||
| 176 | author = {Jane Roe and\tJohn Doe and W. Public}, | ||
| 177 | }"))) | ||
| 178 | (should (equal (reftex-get-bib-names "author" entry) | ||
| 179 | '("Jane Roe" "John Doe" "Public")))) | ||
| 180 | (let ((entry (reftex-parse-bibtex-entry "@article{Foo123, | ||
| 181 | editor = {Jane Roe and\tJohn Doe and W. Public}, | ||
| 182 | }"))) | ||
| 183 | (should (equal (reftex-get-bib-names "author" entry) | ||
| 184 | '("Jane Roe" "John Doe" "Public"))))) | ||
| 185 | |||
| 186 | (ert-deftest reftex-format-citation-test () | ||
| 187 | "Test `reftex-format-citation'." | ||
| 188 | (let ((entry (reftex-parse-bibtex-entry | ||
| 189 | "@article{Foo13, | ||
| 190 | author = {Jane Roe and John Doe and Jane Q. Taxpayer}, | ||
| 191 | title = {Some Article}, | ||
| 192 | journal = {Some Journal}, | ||
| 193 | year = 2013, | ||
| 194 | pages = {1--333} | ||
| 195 | }"))) | ||
| 196 | (should (string= (reftex-format-citation entry nil) "\\cite{Foo13}")) | ||
| 197 | (should (string= (reftex-format-citation entry "%l:%A:%y:%t %j %P %a") | ||
| 198 | "Foo13:Jane Roe:2013:Some Article Some Journal 1 Jane Roe, John Doe \\& Jane Taxpayer")))) | ||
| 199 | |||
| 200 | (provide 'reftex-tests) | ||
| 201 | ;;; reftex-tests.el ends here. | ||