# HG changeset patch # User Romain Francoise # Date 1128197363 0 # Node ID a2bc28552d907a8e3dc4bd7a365d8712ca8253dd # Parent c398c79b323528b73852554e2bfdf87b480cea7e 2005-10-01 Roland Winkler * textmodes/bibtex.el (bibtex-valid-entry-whitespace-re): Do not match newline. (bibtex-realign): Do not use bibtex-valid-entry-whitespace-re. (bibtex-summary): remove unnecessary save-excursion. (bibtex-fill-field-bounds): Use fill-region-as-paragraph. diff -r c398c79b3235 -r a2bc28552d90 lisp/ChangeLog --- a/lisp/ChangeLog Sat Oct 01 12:51:42 2005 +0000 +++ b/lisp/ChangeLog Sat Oct 01 20:09:23 2005 +0000 @@ -1,3 +1,11 @@ +2005-10-01 Roland Winkler + + * textmodes/bibtex.el (bibtex-valid-entry-whitespace-re): + Do not match newline. + (bibtex-realign): Do not use bibtex-valid-entry-whitespace-re. + (bibtex-summary): Remove unnecessary save-excursion. + (bibtex-fill-field-bounds): Use fill-region-as-paragraph. + 2005-10-01 YAMAMOTO Mitsuharu * term/mac-win.el: Add charset info for "iso10646-1". Modify diff -r c398c79b3235 -r a2bc28552d90 lisp/textmodes/bibtex.el --- a/lisp/textmodes/bibtex.el Sat Oct 01 12:51:42 2005 +0000 +++ b/lisp/textmodes/bibtex.el Sat Oct 01 20:09:23 2005 +0000 @@ -1120,7 +1120,7 @@ "Regexp matching the name of a valid BibTeX entry.") (defvar bibtex-valid-entry-whitespace-re - (concat "[ \t\n]*\\(" bibtex-valid-entry-re "\\)") + (concat "[ \t]*\\(" bibtex-valid-entry-re "\\)") "Regexp matching the name of a valid BibTeX entry preceded by whitespace.") (defvar bibtex-any-valid-entry-re @@ -2566,34 +2566,33 @@ "Return summary of current BibTeX entry. Used as default value of `bibtex-summary-function'." ;; It would be neat to customize this function. How? - (save-excursion - (if (looking-at bibtex-entry-maybe-empty-head) - (let* ((bibtex-autokey-name-case-convert 'identity) - (bibtex-autokey-name-length 'infty) - (bibtex-autokey-names 1) - (bibtex-autokey-names-stretch 0) - (bibtex-autokey-name-separator " ") - (bibtex-autokey-additional-names " etal") - (names (bibtex-autokey-get-names)) - (bibtex-autokey-year-length 4) - (year (bibtex-autokey-get-year)) - (bibtex-autokey-titlewords 5) - (bibtex-autokey-titlewords-stretch 2) - (bibtex-autokey-titleword-case-convert 'identity) - (bibtex-autokey-titleword-length 5) - (bibtex-autokey-titleword-separator " ") - (title (bibtex-autokey-get-title)) - (journal (bibtex-autokey-get-field - "journal" bibtex-autokey-transcriptions)) - (volume (bibtex-autokey-get-field "volume")) - (pages (bibtex-autokey-get-field "pages" '(("-.*\\'" . ""))))) - (mapconcat (lambda (arg) - (if (not (string= "" (cdr arg))) - (concat (car arg) (cdr arg)))) - `((" " . ,names) (" " . ,year) (": " . ,title) - (", " . ,journal) (" " . ,volume) (":" . ,pages)) - "")) - (error "Entry not found")))) + (if (looking-at bibtex-entry-maybe-empty-head) + (let* ((bibtex-autokey-name-case-convert 'identity) + (bibtex-autokey-name-length 'infty) + (bibtex-autokey-names 1) + (bibtex-autokey-names-stretch 0) + (bibtex-autokey-name-separator " ") + (bibtex-autokey-additional-names " etal") + (names (bibtex-autokey-get-names)) + (bibtex-autokey-year-length 4) + (year (bibtex-autokey-get-year)) + (bibtex-autokey-titlewords 5) + (bibtex-autokey-titlewords-stretch 2) + (bibtex-autokey-titleword-case-convert 'identity) + (bibtex-autokey-titleword-length 5) + (bibtex-autokey-titleword-separator " ") + (title (bibtex-autokey-get-title)) + (journal (bibtex-autokey-get-field + "journal" bibtex-autokey-transcriptions)) + (volume (bibtex-autokey-get-field "volume")) + (pages (bibtex-autokey-get-field "pages" '(("-.*\\'" . ""))))) + (mapconcat (lambda (arg) + (if (not (string= "" (cdr arg))) + (concat (car arg) (cdr arg)))) + `((" " . ,names) (" " . ,year) (": " . ,title) + (", " . ,journal) (" " . ,volume) (":" . ,pages)) + "")) + (error "Entry not found"))) (defun bibtex-pop (arg direction) "Fill current field from the ARGth same field's text in DIRECTION. @@ -3950,9 +3949,9 @@ (insert " ") (indent-to-column bibtex-text-indentation))) (re-search-forward "[ \t\n]*=[ \t\n]*" end-field)) - (while (re-search-forward "[ \t\n]+" end-field 'move) - (replace-match " ")) - (do-auto-fill) + ;; Paragraphs within fields are not preserved. Bother? + (fill-region-as-paragraph (line-beginning-position) end-field + default-justification nil (point)) (if move (goto-char end-field)))) (defun bibtex-fill-field (&optional justify) @@ -3992,13 +3991,14 @@ (defun bibtex-realign () "Realign BibTeX entries such that they are separated by one blank line." (goto-char (point-min)) - (let ((case-fold-search t)) + (let ((case-fold-search t) + (valid-entry (concat "[ \t\n]*\\(" bibtex-valid-entry-re "\\)"))) ;; No blank lines prior to the first valid entry if there no ;; non-white characters in front of it. - (when (looking-at bibtex-valid-entry-whitespace-re) + (when (looking-at valid-entry) (replace-match "\\1")) ;; Valid entries are separated by one blank line. - (while (re-search-forward bibtex-valid-entry-whitespace-re nil t) + (while (re-search-forward valid-entry nil t) (replace-match "\n\n\\1")) ;; One blank line past the last valid entry if it is followed by ;; non-white characters, no blank line otherwise.