From: Roland Winkler Date: Sun, 9 Apr 2006 18:25:53 +0000 (+0000) Subject: (bibtex-find-text-internal): Add new element string-const to return value. X-Git-Tag: emacs-pretest-22.0.90~3257 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ba7e3f51f264729f3ef2b91e11c0cee46ad67509;p=emacs.git (bibtex-find-text-internal): Add new element string-const to return value. (bibtex-remove-delimiters): Use it. --- 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." (defun bibtex-find-text-internal (&optional noerror subfield comma) "Find text part of current BibTeX field or entry head. -Return list (NAME START-TEXT END-TEXT END) with field or entry name, -start and end of text and end of field or entry head, or nil if not found. -If optional arg NOERROR is non-nil, an error message is suppressed if text -is not found. If optional arg SUBFIELD is non-nil START-TEXT and END-TEXT -correspond to the current subfield delimited by #. +Return list (NAME START-TEXT END-TEXT END STRING-CONST) with field +or entry name, start and end of text, and end of field or entry head. +STRING-CONST is a flag which is non-nil if current subfield delimited by # +is a BibTeX string constant. Return value is nil if field or entry head +are not found. +If optional arg NOERROR is non-nil, an error message is suppressed +if text is not found. If optional arg SUBFIELD is non-nil START-TEXT +and END-TEXT correspond to the current subfield delimited by #. Optional arg COMMA is as in `bibtex-enclosing-field'." (save-excursion (let ((pnt (point)) (bounds (bibtex-enclosing-field comma t)) (case-fold-search t) - name start-text end-text end failure done no-sub) + name start-text end-text end failure done no-sub string-const) (bibtex-beginning-of-entry) (cond (bounds (setq name (bibtex-name-in-field bounds t) @@ -3667,9 +3670,11 @@ Optional arg COMMA is as in `bibtex-enclosing-field'." (goto-char start-text) (while (not done) (if (or (prog1 (looking-at bibtex-field-const) - (setq end-text (match-end 0))) + (setq end-text (match-end 0) + string-const t)) (prog1 (setq bounds (bibtex-parse-field-string)) - (setq end-text (cdr bounds)))) + (setq end-text (cdr bounds) + string-const nil))) (progn (if (and (<= start-text pnt) (<= pnt end-text)) (setq done t) @@ -3678,7 +3683,7 @@ Optional arg COMMA is as in `bibtex-enclosing-field'." (setq start-text (goto-char (match-end 0))))) (setq done t failure t))))) (cond ((not failure) - (list name start-text end-text end)) + (list name start-text end-text end string-const)) ((and no-sub (not noerror)) (error "Not on text part of BibTeX field")) ((not noerror) (error "Not on BibTeX field")))))) @@ -3712,13 +3717,10 @@ is as in `bibtex-enclosing-field'. It is t for interactive calls." Optional arg COMMA is as in `bibtex-enclosing-field'. It is t for interactive calls." (interactive (list t)) - (let* ((bounds (bibtex-find-text-internal nil t comma)) - (start (nth 1 bounds)) - (end (nth 2 bounds))) - (if (memq (char-before end) '(?\} ?\")) - (delete-region (1- end) end)) - (if (memq (char-after start) '(?\{ ?\")) - (delete-region start (1+ start))))) + (let ((bounds (bibtex-find-text-internal nil t comma))) + (unless (nth 4 bounds) + (delete-region (1- (nth 2 bounds)) (nth 2 bounds)) + (delete-region (nth 1 bounds) (1+ (nth 1 bounds)))))) (defun bibtex-kill-field (&optional copy-only comma) "Kill the entire enclosing BibTeX field.