unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: [jochen@fhi-berlin.mpg.de: bibtex-generate-url-list enhancement]
       [not found] <E1DDqF9-0000nR-Kv@fencepost.gnu.org>
@ 2005-03-30 13:24 ` Roland Winkler
       [not found] ` <16970.37875.452394.32109@tfkp12.physik.uni-erlangen.de>
  1 sibling, 0 replies; 5+ messages in thread
From: Roland Winkler @ 2005-03-30 13:24 UTC (permalink / raw)



> Maybe the following enhanced definition can be put into emacs'
> bibtex.el:
> ,----
> |       bibtex-generate-url-list '((("doi" . "")
> |                                   "http://dx.doi.org/"
> |                                   ("doi" ".*" 0))
> |                                  (("url" . ".*:.*"))
> |                                  (("journal" . "\\<\\(PR[ABCDEL]?\\|RMP\\)\\>")
> |                                   "http://link.aps.org/abstract/"
> |                                   ("journal" ".*" downcase)
> |                                   "/v" ("volume" ".*" 0)
> |                                   "/p" ("pages" "\\`\\([0-9]+\\)" 1))
> |                                  (("journal" . "\\<\\(APL\\|JAP\\|JCP\\|JMP\\|JPCRD\\|RSI\\)\\>")
> |                                   "http://link.aip.org/link/?"
> |                                   ("journal" ".*" upcase)
> |                                   "/" ("volume" ".*" 0)
> |                                   "/" ("pages" "\\`\\([0-9]+\\)" 1)
> |                                   "/" "1"))
> `----
> It adds support for journal from one additional publisher (AIP) and
> also the more general case of using a DOI [1], which are really what
> should be used today in a database to refer to online content.
> 
> It would also be nice to have DOI in bibtex-entry-field-alist (as
> optional entry for all entry types) and to have the field buttonized
> if available (just like url or journal (if prl/jcp/or such).

Hi Jochen

Thanks a lot for these suggestions. However, I hesitate to put these
changes into bibtex.el. It appears to me that the above value for
bibtex-generate-url-list reflect your personal preferences so that
they should go into the personal .emacs:

- The default values for user variables in bibtex.el reflect the
  usage of BibTeX as a bibliography database for LaTeX documents. To
  the best of my knowledge, neither URLs nor DOIs are required for
  LaTeX documents.

  The default value for bibtex-generate-url-list is an example for
  how to use this variable.

- The buttons for URLs in BibTeX files are inserted via font-lock.
  The algorithm is fairly complicated. I expect that a long list of
  schemes in bibtex-generate-url-list can make font-locking rather
  slow if one has a slow computer and/or a large BibTeX file.
  (Comments welcome! I can't check that on my computer, it's pretty
  fast.)

  On the other hand, the algorithm is fully customizable. If the
  journals you work with support DOIs, you can add a DOI field to
  bibtex-user-optional-fields. And the above value for
  bibtex-generate-url-list will generate buttons for these fields.

  Let me know if there is anything that cannot be done by
  appropriate values for bibtex-user-optional-fields and
  bibtex-generate-url-list.

- It seems to me that your choice of journals from AIP reflects your
  personal preferences. See http://link.aip.org/jhtml/rre_list.jsp
  for a more complete list of AIP journals. However, this rather
  long list of journal names would make font-locking even slower.
  (The British IOP and the European EPS use similar schemes for
  their journals.)

  In my .emacs, I have pretty much the same value for
  bibtex-generate-url-list you suggest. (I expect that you are a
  physicist like me. You are interested in the same journals.)

Roland

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [jochen-+It19tn3Rl9sbm7dSapR3bNAH6kLmebB@public.gmane.org: bibtex-generate-url-list enhancement]
       [not found]   ` <16970.37875.452394.32109-iRV971lXqr8zLOUDZFttzH20dTPRyWU8FLXUG6abMr4@public.gmane.org>
@ 2005-03-30 18:16     ` Jochen Küpper
  2005-03-30 19:41       ` [jochen@fhi-berlin.mpg.de: " Roland Winkler
  0 siblings, 1 reply; 5+ messages in thread
From: Jochen Küpper @ 2005-03-30 18:16 UTC (permalink / raw)
  Cc: emacs-devel-f8S/fY/i+OUiq3RsQ1AnAw, rms-mXXj517/zsQ

Roland Winkler <roland.winkler-PRwTpj6vllKd8VzsmqXLk2HfThorsUsI@public.gmane.org> writes:

>> Maybe the following enhanced definition can be put into emacs'
>> bibtex.el:
[...]

> Thanks a lot for these suggestions. However, I hesitate to put these
> changes into bibtex.el. It appears to me that the above value for
> bibtex-generate-url-list reflect your personal preferences so that
> they should go into the personal .emacs:

Well, there they are already;)

Generally I can follow your argumentation quite well. I thought that
generally we could help users a lot on the convenience side, however
do I not wanna overrule users of slow computers.

A few remaining remarks:

> - The default values for user variables in bibtex.el reflect the
> usage of BibTeX as a bibliography database for LaTeX documents. To
> the best of my knowledge, neither URLs nor DOIs are required for
> LaTeX documents.

Not required, but URL is used by natbib and therefore quite common. It
really does not hurt anybody, but it helps a large number of people.
Anyway, it is supported by bibtex.el already.

That does not hold for DOI, and although I think that would actually
be the right approach (instead of URL), I have no convincing arguments
for it.

>   The default value for bibtex-generate-url-list is an example for
>   how to use this variable.

Ok, here the problem starts. If you follow your own argumentation, you
should probably remove all the journal stuff from there and move them
into the documentation. To me the current status looked like the
beginning of a long list, where I thought I start to send in a few
more entries. I'd say it is really all or none; with respect to "slow
systems" it should be none then.

Maybe it would be useful to define variables ala
  bibtex-generate-url-list-chemistry
  bibtex-generate-url-list-history
  bibtex-generate-url-list-math
  bibtex-generate-url-list-physics
  bibtex-generate-url-list-philosophy
and then let users plug them into bibtex-generate-url-list as they wish?


Another question: I have a function, defined as below, which gets me a
PDF from my private archive based on the entry's key (Not a "key = {}"
item, but the actual "@Article{key," value.). Is there a way to hook
that into the bibtex-generate-url machinery?
,----
| (defvar jk/bibtex-pdf-location (concat jk/home-dir "/PDF"))
| (defvar jk/bibtex-pdf-viewer "acroread" "PDF viewer")
| (defun jk/bibtex-view-pdf ()
|   "*Open PDF from archive.
| 
| This function determines the filename corresponding to the current entry and
| opens the associated file form the archive.
| "
|   (interactive)
|   (save-excursion
|     (bibtex-narrow-to-entry)
|     (bibtex-beginning-of-entry)
|     (let ((name (substring (buffer-substring-no-properties (point-min) (point-max))
|                            (+ 1 (string-match "{" (buffer-string))) (string-match "," (buffer-string)))))
|       (subst-char-in-string (string-to-char ":") (string-to-char "_") name t)
|       (message (concat "Opening " jk/bibtex-pdf-viewer " " jk/bibtex-pdf-location "/" name ".pdf..."))
|       (start-process-shell-command "acroread" nil
|                                    (concat jk/bibtex-pdf-viewer " "
|                                            jk/bibtex-pdf-location "/" (substring name 0 1) "/"
|                                            name ".pdf&"))
|       (message ""))
|     (widen)))
| (eval-after-load "bibtex" '(define-key bibtex-mode-map [(control v)] 'jk/bibtex-view-pdf))
`----


Anyway, I do appreciate the improvements to bibtex.el a lot. 
Thanks for your work!

Greetings,
Jochen

PS: Yes, I am practically a physicist -- no, not by training;)
-- 
Einigkeit und Recht und Freiheit                http://www.Jochen-Kuepper.de
    Liberté, Égalité, Fraternité                GnuPG key: CC1B0B4D
        (Part 3 you find in my messages before fall 2003.)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [jochen@fhi-berlin.mpg.de: bibtex-generate-url-list enhancement]
  2005-03-30 18:16     ` [jochen-+It19tn3Rl9sbm7dSapR3bNAH6kLmebB@public.gmane.org: " Jochen Küpper
@ 2005-03-30 19:41       ` Roland Winkler
       [not found]         ` <16971.242.974710.569348-iRV971lXqr8zLOUDZFttzH20dTPRyWU8FLXUG6abMr4@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Roland Winkler @ 2005-03-30 19:41 UTC (permalink / raw)
  Cc: rms, emacs-devel

On Wed Mar 30 2005 Jochen Küpper wrote:
> Another question: I have a function, defined as below, which gets me a
> PDF from my private archive based on the entry's key (Not a "key = {}"
> item, but the actual "@Article{key," value.). Is there a way to hook
> that into the bibtex-generate-url machinery?

As the docstring for bibtex-generate-url-list says

    Each scheme is of the form ((FIELD . REGEXP) STEP...).

    FIELD is a field name as returned by `bibtex-parse-entry'.

The alist returned by bibtex-parse-entry includes the key (see
there). So bibtex-url can use it and it seems to me that your
command jk/bibtex-view-pdf is not needed at all. Try the scheme
(untested)

    (("=key=" . ".*")
     ,jk/bibtex-pdf-location
     ("=key=" ".*" 0))

The only thing currently you cannot do is use the key as a button.
(You must use the command bibtex-url bound to C-c C-l.) This is
because bibtex-url and bibtex-font-lock-url use rather different
algorithms.

Would it be useful to have a function bibtex-font-lock-url-key?
I guess I wouldn't want to use it because it would be difficult to
specify which keys should be buttonized. But this might be a matter
of taste. (However, I was told that emacs is in feature freeze. So
in any case I'd prefer to wait with a new function
bibtex-font-lock-url-key till the new version of emacs has been
released.)

Roland

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [jochen-+It19tn3Rl9sbm7dSapR3bNAH6kLmebB@public.gmane.org: bibtex-generate-url-list enhancement]
       [not found]         ` <16971.242.974710.569348-iRV971lXqr8zLOUDZFttzH20dTPRyWU8FLXUG6abMr4@public.gmane.org>
@ 2005-03-30 21:43           ` Jochen Küpper
       [not found]             ` <m3zmwkollx.fsf-X+QEHg5KIgm/8B4OpmtwqPxnRIzENc/G@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Jochen Küpper @ 2005-03-30 21:43 UTC (permalink / raw)
  Cc: rms-mXXj517/zsQ, emacs-devel-mXXj517/zsQ

Roland Winkler <roland.winkler-PRwTpj6vllKd8VzsmqXLk2HfThorsUsI@public.gmane.org> writes:

> The alist returned by bibtex-parse-entry includes the key (see
> there). So bibtex-url can use it and it seems to me that your
> command jk/bibtex-view-pdf is not needed at all. Try the scheme
> (untested)
>
>     (("=key=" . ".*")
>      ,jk/bibtex-pdf-location
>      ("=key=" ".*" 0))

Hmm, that I got not working (most probably due to my limited lisp
knowledge; tried a regexp replace ala "\0_\1_\2.pdf" and also using
(format ...)). 

That is, I actually need to perform a few transformations on the key
to get the filename. However, it still works quite nicely when using
the following bibtex-generate-url-list entry:

     (("=key=" . ".*")
      ("=key=" ".*" jk/bibtex-pdf-name))

and a simple transformation function

(defun jk/bibtex-pdf-name (key)
  "Determine filename in PDF databse from bibtex key.

This function determines the filename corresponding to the current entry.
"
  (progn
    (subst-char-in-string (string-to-char ":") (string-to-char "_") key t)
    (concat jk/bibtex-pdf-location "/" (substring key 0 1) "/" key  ".pdf")))


I am sure someone could do that using a smart regexp replace, but this
I understand;) I do assume that a regexp/replace solution might be
faster?

> The only thing currently you cannot do is use the key as a button.
> (You must use the command bibtex-url bound to C-c C-l.) This is
> because bibtex-url and bibtex-font-lock-url use rather different
> algorithms.

No problem for me. (But I do know some people who will only use this
with clickable keys...)


Thanks for your help.

Greetings,
Jochen
-- 
Fritz-Haber-Institut der MPG -- Abteilung Molekülphysik
Faradayweg 4-6 (C1.03)
D-14195 Berlin

phone: +49-30-84135686
fax:   +49-30-84135892

^ permalink raw reply	[flat|nested] 5+ messages in thread

* bibtex-generate-url-list
       [not found]             ` <m3zmwkollx.fsf-X+QEHg5KIgm/8B4OpmtwqPxnRIzENc/G@public.gmane.org>
@ 2005-04-01 12:51               ` Jochen Küpper
  0 siblings, 0 replies; 5+ messages in thread
From: Jochen Küpper @ 2005-04-01 12:51 UTC (permalink / raw)
  Cc: emacs-devel-mXXj517/zsQ

Ok, so lets assume I have the following setting
,----
|       bibtex-generate-url-list '((("=key=" . ".*")
|                                   ("=key=" ".*" jk/bibtex-pdf-name))
|                                  (("doi" . "10\\..*/.*")
|                                   "http://dx.doi.org/"
|                                   ("doi" ".*" 0))
|                                  (("url" . ".*:.*")))
`----
and
,----
| (defvar jk/bibtex-pdf-location (concat jk/home-dir "/PDF") "Location of PDF archive")
| (defun jk/bibtex-pdf-name (key)
|   "Determine filename in PDF databse from bibtex key.
| 
| This function determines the filename corresponding to the current entry.
| "
|   (progn
|     (subst-char-in-string (string-to-char ":") (string-to-char "_") key t)
|     (concat jk/bibtex-pdf-location "/" (substring key 0 1) "/" key  ".pdf")))
`----

This will, obviously, always try to open a file in my local archive
and never use the doi or url fields. What I actually want is that the
file from the archive is used *if* available, the doi/url otherwise.

I can supply a function to check for the availability in the archive,
but is there any way to have bibtex-url go back and use the next entry
if the file is not available?

If not, I guess I can write a function around bibtex-url that checks
for the availability of the local file and opens it if its there, but
use bibtex-url without the local source otherwise... Doesn't sound
like the cleanest approach, though.

Greetings,
Jochen
-- 
Einigkeit und Recht und Freiheit                http://www.Jochen-Kuepper.de
    Liberté, Égalité, Fraternité                GnuPG key: CC1B0B4D
        (Part 3 you find in my messages before fall 2003.)

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-04-01 12:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <E1DDqF9-0000nR-Kv@fencepost.gnu.org>
2005-03-30 13:24 ` [jochen@fhi-berlin.mpg.de: bibtex-generate-url-list enhancement] Roland Winkler
     [not found] ` <16970.37875.452394.32109@tfkp12.physik.uni-erlangen.de>
     [not found]   ` <16970.37875.452394.32109-iRV971lXqr8zLOUDZFttzH20dTPRyWU8FLXUG6abMr4@public.gmane.org>
2005-03-30 18:16     ` [jochen-+It19tn3Rl9sbm7dSapR3bNAH6kLmebB@public.gmane.org: " Jochen Küpper
2005-03-30 19:41       ` [jochen@fhi-berlin.mpg.de: " Roland Winkler
     [not found]         ` <16971.242.974710.569348-iRV971lXqr8zLOUDZFttzH20dTPRyWU8FLXUG6abMr4@public.gmane.org>
2005-03-30 21:43           ` [jochen-+It19tn3Rl9sbm7dSapR3bNAH6kLmebB@public.gmane.org: " Jochen Küpper
     [not found]             ` <m3zmwkollx.fsf-X+QEHg5KIgm/8B4OpmtwqPxnRIzENc/G@public.gmane.org>
2005-04-01 12:51               ` bibtex-generate-url-list Jochen Küpper

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).