From: Jim Ottaway <j.ottaway@lse.ac.uk>
Subject: Re: bibtex-mode wishes
Date: Fri, 10 Jan 2003 19:20:51 +0000 [thread overview]
Message-ID: <8765swn758.fsf@lse.ac.uk> (raw)
In-Reply-To: 87iswza76o.fsf@antithese.de
>>>>> "Michael" == Michael Below <mbelow@antithese.de> writes:
> - If I crossreference an entry, the referencing entry should be
> sorted before the entry referenced to, otherwise bibtex wont be
> able to solve the reference.
I have changed `bibtex-sort-buffer' to achieve this by fiddling with
the sort keys:
(defun bibtex-sort-buffer ()
"Sort BibTeX buffer alphabetically by key.
Text outside of BibTeX entries is not affected. If
`bibtex-sort-ignore-string-entries' is non-nil, @String entries will be
ignored."
(interactive)
(save-restriction
(narrow-to-region
(bibtex-beginning-of-first-entry)
(save-excursion
(goto-char (point-max))
(bibtex-end-of-entry)))
(bibtex-skip-to-valid-entry)
(sort-subr
nil
;; NEXTREC function
'bibtex-skip-to-valid-entry
;; ENDREC function
'bibtex-end-of-entry
;; STARTKEY function
(lambda ()
(let* ((case-fold-search t)
key entry-end xref-match)
(re-search-forward bibtex-entry-head)
(setq key
(buffer-substring-no-properties
(match-beginning bibtex-key-in-head)
(match-end bibtex-key-in-head)))
(save-excursion
(bibtex-end-of-entry)
(setq entry-end (point)))
(if (re-search-forward
"^[ \t]*crossref[ \t]*=[ \t]*"
entry-end t)
;; If there is a cross-reference, make a new key that
;; will be less than the cross-referred item's key.
(progn
(setq xref-match (bibtex-search-forward-field-string entry-end))
(concat (buffer-substring-no-properties
;; Trim the braces/quotes and replace the last
;; character of the key with a space
;; (makes it string< than book key).
;; Concatenate this with the actual entry key,
;; so that it is sorted properly with other
;; entries with the same cross-reference.
(1+ (car xref-match))
(- (cdr xref-match) 2))
" "
key))
key))))))
It seems to work; perhaps I should send this to the maintainer.
Regards,
Jim Ottaway
next prev parent reply other threads:[~2003-01-10 19:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-08 17:21 bibtex-mode wishes Michael Below
2003-01-08 18:16 ` Roland Winkler
2003-01-08 20:35 ` Michael Below
2003-01-10 19:20 ` Jim Ottaway [this message]
2003-01-12 20:25 ` Stefan Monnier <foo@acm.com>
2003-01-17 14:03 ` Jim Ottaway
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8765swn758.fsf@lse.ac.uk \
--to=j.ottaway@lse.ac.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.