diff options
| author | Roland Winkler | 2006-04-09 18:25:53 +0000 |
|---|---|---|
| committer | Roland Winkler | 2006-04-09 18:25:53 +0000 |
| commit | ba7e3f51f264729f3ef2b91e11c0cee46ad67509 (patch) | |
| tree | 375ef719fcb6ac23a053d615a3124853b2165442 | |
| parent | af26e6739b17f39b0e85ec9b6948ddd9534c345e (diff) | |
| download | emacs-ba7e3f51f264729f3ef2b91e11c0cee46ad67509.tar.gz emacs-ba7e3f51f264729f3ef2b91e11c0cee46ad67509.zip | |
(bibtex-find-text-internal): Add new element string-const to return value.
(bibtex-remove-delimiters): Use it.
| -rw-r--r-- | lisp/textmodes/bibtex.el | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/lisp/textmodes/bibtex.el b/lisp/textmodes/bibtex.el index daca0502454..a70ab1591ca 100644 --- a/lisp/textmodes/bibtex.el +++ b/lisp/textmodes/bibtex.el | |||
| @@ -3613,17 +3613,20 @@ interactive calls." | |||
| 3613 | 3613 | ||
| 3614 | (defun bibtex-find-text-internal (&optional noerror subfield comma) | 3614 | (defun bibtex-find-text-internal (&optional noerror subfield comma) |
| 3615 | "Find text part of current BibTeX field or entry head. | 3615 | "Find text part of current BibTeX field or entry head. |
| 3616 | Return list (NAME START-TEXT END-TEXT END) with field or entry name, | 3616 | Return list (NAME START-TEXT END-TEXT END STRING-CONST) with field |
| 3617 | start and end of text and end of field or entry head, or nil if not found. | 3617 | or entry name, start and end of text, and end of field or entry head. |
| 3618 | If optional arg NOERROR is non-nil, an error message is suppressed if text | 3618 | STRING-CONST is a flag which is non-nil if current subfield delimited by # |
| 3619 | is not found. If optional arg SUBFIELD is non-nil START-TEXT and END-TEXT | 3619 | is a BibTeX string constant. Return value is nil if field or entry head |
| 3620 | correspond to the current subfield delimited by #. | 3620 | are not found. |
| 3621 | If optional arg NOERROR is non-nil, an error message is suppressed | ||
| 3622 | if text is not found. If optional arg SUBFIELD is non-nil START-TEXT | ||
| 3623 | and END-TEXT correspond to the current subfield delimited by #. | ||
| 3621 | Optional arg COMMA is as in `bibtex-enclosing-field'." | 3624 | Optional arg COMMA is as in `bibtex-enclosing-field'." |
| 3622 | (save-excursion | 3625 | (save-excursion |
| 3623 | (let ((pnt (point)) | 3626 | (let ((pnt (point)) |
| 3624 | (bounds (bibtex-enclosing-field comma t)) | 3627 | (bounds (bibtex-enclosing-field comma t)) |
| 3625 | (case-fold-search t) | 3628 | (case-fold-search t) |
| 3626 | name start-text end-text end failure done no-sub) | 3629 | name start-text end-text end failure done no-sub string-const) |
| 3627 | (bibtex-beginning-of-entry) | 3630 | (bibtex-beginning-of-entry) |
| 3628 | (cond (bounds | 3631 | (cond (bounds |
| 3629 | (setq name (bibtex-name-in-field bounds t) | 3632 | (setq name (bibtex-name-in-field bounds t) |
| @@ -3667,9 +3670,11 @@ Optional arg COMMA is as in `bibtex-enclosing-field'." | |||
| 3667 | (goto-char start-text) | 3670 | (goto-char start-text) |
| 3668 | (while (not done) | 3671 | (while (not done) |
| 3669 | (if (or (prog1 (looking-at bibtex-field-const) | 3672 | (if (or (prog1 (looking-at bibtex-field-const) |
| 3670 | (setq end-text (match-end 0))) | 3673 | (setq end-text (match-end 0) |
| 3674 | string-const t)) | ||
| 3671 | (prog1 (setq bounds (bibtex-parse-field-string)) | 3675 | (prog1 (setq bounds (bibtex-parse-field-string)) |
| 3672 | (setq end-text (cdr bounds)))) | 3676 | (setq end-text (cdr bounds) |
| 3677 | string-const nil))) | ||
| 3673 | (progn | 3678 | (progn |
| 3674 | (if (and (<= start-text pnt) (<= pnt end-text)) | 3679 | (if (and (<= start-text pnt) (<= pnt end-text)) |
| 3675 | (setq done t) | 3680 | (setq done t) |
| @@ -3678,7 +3683,7 @@ Optional arg COMMA is as in `bibtex-enclosing-field'." | |||
| 3678 | (setq start-text (goto-char (match-end 0))))) | 3683 | (setq start-text (goto-char (match-end 0))))) |
| 3679 | (setq done t failure t))))) | 3684 | (setq done t failure t))))) |
| 3680 | (cond ((not failure) | 3685 | (cond ((not failure) |
| 3681 | (list name start-text end-text end)) | 3686 | (list name start-text end-text end string-const)) |
| 3682 | ((and no-sub (not noerror)) | 3687 | ((and no-sub (not noerror)) |
| 3683 | (error "Not on text part of BibTeX field")) | 3688 | (error "Not on text part of BibTeX field")) |
| 3684 | ((not noerror) (error "Not on BibTeX field")))))) | 3689 | ((not noerror) (error "Not on BibTeX field")))))) |
| @@ -3712,13 +3717,10 @@ is as in `bibtex-enclosing-field'. It is t for interactive calls." | |||
| 3712 | Optional arg COMMA is as in `bibtex-enclosing-field'. It is t for | 3717 | Optional arg COMMA is as in `bibtex-enclosing-field'. It is t for |
| 3713 | interactive calls." | 3718 | interactive calls." |
| 3714 | (interactive (list t)) | 3719 | (interactive (list t)) |
| 3715 | (let* ((bounds (bibtex-find-text-internal nil t comma)) | 3720 | (let ((bounds (bibtex-find-text-internal nil t comma))) |
| 3716 | (start (nth 1 bounds)) | 3721 | (unless (nth 4 bounds) |
| 3717 | (end (nth 2 bounds))) | 3722 | (delete-region (1- (nth 2 bounds)) (nth 2 bounds)) |
| 3718 | (if (memq (char-before end) '(?\} ?\")) | 3723 | (delete-region (nth 1 bounds) (1+ (nth 1 bounds)))))) |
| 3719 | (delete-region (1- end) end)) | ||
| 3720 | (if (memq (char-after start) '(?\{ ?\")) | ||
| 3721 | (delete-region start (1+ start))))) | ||
| 3722 | 3724 | ||
| 3723 | (defun bibtex-kill-field (&optional copy-only comma) | 3725 | (defun bibtex-kill-field (&optional copy-only comma) |
| 3724 | "Kill the entire enclosing BibTeX field. | 3726 | "Kill the entire enclosing BibTeX field. |