;;; hep-th.el --- tools for hep-th. ;; Copyright (C) 2003 Masaki Shigemori ;; Author: Masaki Shigemori ;; Created: 02 Sep 2003 ;; Keywords: physics, SPIRES HEP, arxiv, hep-th ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 2, or (at your option) ;; any later version. ;; ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA. ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Commentary: ;; ;; see http://www.physics.ucla.edu/~shige/computer/hep-th.el.html ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Code: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; variables (defvar hep-th-default-bib-format 'latex "*Format of bibliography. The bibliography entries are inserted using this format when hep-th-insert-bib is called. Possible options are 'latex (default), 'latex2, 'bibtex, and 'harvmac, each corresponding to LaTeX(US), LaTeX(EU), Harvmac, and BibTeX of SPIRES HEP.") (defvar hep-th-bib-uncomment-title nil "*When non-nil, the title which is originally commented out in SPIRES HEP out is uncommented when bibl. data is inserted.") (defvar hep-th-default-arxiv-name "hep-th" "*Default arxiv name. If arxiv name is not provided (such as yymmnnn instead of hep-th/yymmnnn), this arxiv name is added. Default value is \"hep-th\".") (defvar hep-th-use-arxiv.org-for-arxiv-number nil "*If t, use arxiv.org instead of SPIRES HEP to browse a paper designated by an arxiv number arxiv-name/yymmnnn.") (defvar hep-th-bibtex-filename nil "*BibTeX file used in hep-th-cite-label-to-arxiv-number. If nil, the one in the \\bibliography command is used instead.") (defvar hep-th-browser-function 'browse-url "*Function for browsing URLs. If you want to use emacs-w3m, do (setq hep-th-browser-function 'w3m)") (defvar hep-th-inspire-hostname "inspirehep.net" "*URL to send SPIRES HEP query commands.") (defvar hep-th-arxiv.org/abs-url "http://arxiv.org/abs" "*URL to browse abstract at arxiv.org") (defvar hep-th-spires-default-format "www" "*\"Format\" attribute to be sent to SPIRES HEP. Possible values are \"www\" : Default WWW Output (default) \"wwwcite\" : Citations \"wwwcitesummary\" : Citation Summary \"wwwbriefbibtex\" : BibTeX \"wwwbrieflatex\" : LaTeX (US) \"wwwbrieflatex2\" : LaTeX (EU) \"wwwbriefharvmac\" : Harvmac \"wwwbrieflatex3\" : CV Format \"wwwbrief\" : Brief \"wwwresult\" : Result Only \"brief\" : No HTML \"wwwfnal\" : Fermilab Format (WWWFNAL) ") (defvar hep-th-spires-default-sort-by "" "*\"Sort by\" attribute to be sent to SPIRES HEP. Possible values are \"\" : No Sort (default) \"ds(d)\" : Date Order - Descending \"ds(a)\" : Date Order - Ascending \"AU\" : 1st Author \"T\" : Title \"AU,T\" : 1st Author, Title ") (defvar hep-th-retrieve-url-sleep-interval .1 "*Unit of sleep time interval for hep-th-retrieve-url (in seconds). It is probably never necessary to change the default value.") (defvar hep-th-input-history nil "Holds the history of the inputs") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; functions (defun hep-th-retrieve-url (url &optional wait) "Retrieve url from http server. No return value. Output is fed into a new buffer. Returns the process. Use process-buffer to obtain the buffer. If WAIT is non-nil, waits until the process closes." (let ((buf (get-buffer-create (concat " *hep-th web conection* <" url ">"))) proc host port path) (save-excursion (set-buffer buf) ; select temp buffer (erase-buffer) ; clean temp buffer (if (string-match "^http://\\([^/]+\\)\\(:\\([0-9]+\\)\\)?\\(/.+\\)$" url) (setq host (match-string 1 url) port (match-string 3 url) path (match-string 4 url))) (if (not port) (setq port 80)) (setq proc (open-network-stream "hep-th-web-connection" buf host port)) (if (>= emacs-major-version 20) (set-process-coding-system proc 'binary 'binary)) (process-send-string proc (format (concat "GET " path " HTTP/1.1\r\n" "Host: " hep-th-inspire-hostname "\r\n" "Connection: close\r\n" ; otherwise retrieval takes time "\r\n"))) ; wait until the process closes (if wait (while (eq (process-status proc) 'open) (sit-for hep-th-retrieve-url-sleep-interval))) proc))) (defun hep-th-arxiv-number-to-key (arxiv-number) "From ARXIV-NUMBER, obtain SPIRES HEP key, and returns the key. ARXIV-NUMBER should of the form yymm.nnnn or arxiv/yymmnnn." (interactive) (let (proc key) (save-excursion (setq proc (hep-th-retrieve-url (concat "http://" hep-th-inspire-hostname "/search?p=FIND+EPRINT+" arxiv-number) t)) ; t means to wait until connection closes (set-buffer (process-buffer proc)) (setq case-fold-search t) (beginning-of-buffer) (if (re-search-forward "/record/\\([0-9]+\\)" nil t) (setq key (match-string 1))) key))) (defun hep-th-key-to-bib (key &optional format) "From SPIRES HEP key, fetch bibliographic data from SPIRES HEP. Returns the bibliographic data. FORMAT is 'latex (default), 'latex2, 'harvmac, or 'bibtex." (interactive) (let (proc start end found-key format-selector) (save-excursion (if (not format) (setq format 'latex)) (cond ((eq format 'bibtex) (setq format-selector "hx")) ((eq format 'latex) (setq format-selector "hlxu")) ((eq format 'latex2) (setq format-selector "hlxe")) ((eq format 'harvmac)(setq format-selector "hlxh")) (t (setq selector "hlxu"))) (setq proc (hep-th-retrieve-url (concat "http://" hep-th-inspire-hostname "/record/" key "/export/" format-selector) t)) ; t means to wait until connection closes (set-buffer (process-buffer proc)) (setq case-fold-search t) ; replacements (beginning-of-buffer) (perform-replace " " " " nil nil nil) (beginning-of-buffer) (perform-replace "
" "\n" nil nil nil) ; search for key. (beginning-of-buffer) ; First, look for the first occurrence of
 
    (if (re-search-forward "
[ \n\t\r]*" nil t)
	(setq start (match-end 0)))
    ; then look for the first occurrence of 
(if (re-search-forward "[ \n\t\r]*
" nil t) (setq end (match-beginning 0))) (cond ((and start end) (buffer-substring start end)) (t nil) )))) (defun hep-th-trim (string) "Trims white space before and after STRING, and returns the result." (let (start end) (if (string-match "^[ \r\n\t]*" string) (setq start (match-end 0))) (if (string-match "[ \r\n\t]*$" string) (setq end (match-beginning 0))) (substring string start end) )) (defun hep-th-arxiv-number-p (arxiv-number) "Check if ARXIV-NUMBER is a valid arxiv number (of the form arXiv:yymm.nnnn, arxiv-name/yymmnnn, or just yymmnnn). If yes, returns ARXIV-NUMBER itself. If no, returns nil. If no arxiv name is provided, add the default arxiv name (hep-th-default-arxiv-name)." (setq arxiv-number (hep-th-trim arxiv-number)) (cond ((string-match "^\\(arXiv:\\)?[ \t]?\\([0-9][0-9][0-9][0-9]\\.[0-9][0-9][0-9][0-9]\\)$" arxiv-number) ; yymm.nnnn (match-string 2 arxiv-number)) ((string-match "^[0-9][0-9][0-9][0-9][0-9][0-9][0-9]$" arxiv-number) (setq arxiv-number (concat hep-th-default-arxiv-name "/" arxiv-number))) ; if just yymmnnn, add hep-th-default-arxiv-name ((string-match "^[a-zA-Z]+[-\\.][a-zA-Z]+/[0-9][0-9][0-9][0-9][0-9][0-9][0-9]$" arxiv-number) arxiv-number) (t nil))) (defun hep-th-read-bib-format () "Input bibliographic format from keyboard. Returns the format ('latex, 'latex2, 'harvmac, or 'bibtex)." (let (char) (message (concat "Bibl. format: " "l(LaTeX(US)) " "L(LaTeX(EU)) " "h(Harvmac) " "b(BibTeX) ")) (setq char (read-char)) (cond ((char-equal char ?l) 'latex) ((char-equal char ?L) 'latex2) ((char-equal char ?h) 'harvmac) ((char-equal char ?b) 'bibtex) (t hep-th-default-bib-format)))) (defun hep-th-insert-bib (&optional arg) "Insert bibliographic data of the paper at point. If ARG is non-nil, prompt for bibl. format." (interactive "P") (let (key bib title-start title-end bib-before-title bib-title bib-after-title percent arxiv-number bib-format char) (setq arxiv-number (read-from-minibuffer "Arxiv number (yymm.nnnn or arxiv-name/yymmnnn): " nil nil nil 'hep-th-input-history)) (if arg (setq bib-format (hep-th-read-bib-format)) (setq bib-format hep-th-default-bib-format)) (if (setq arxiv-number (hep-th-arxiv-number-p arxiv-number)) (progn (message "retrieving key..") (setq key (hep-th-arxiv-number-to-key arxiv-number)) (cond (key ; if key is retrieved successfully (message "retrieving bibliographic data..") (setq bib (hep-th-key-to-bib key bib-format)) (cond (bib ; if bib is retrieved successfully ; uncomment title if necessary (cond (hep-th-bib-uncomment-title (setq title-start (string-match "%``" bib)) (setq title-end (string-match "''" bib title-start)) (if (and title-start title-end) (progn (setq title-end (+ title-end 2)) (setq bib-before-title (substring bib 0 title-start) bib-title (substring bib title-start title-end) bib-after-title (substring bib title-end)) (while (setq percent (string-match "%" bib-title)) (setq bib-title (concat (substring bib-title 0 percent) (substring bib-title (+ percent 1))))) (setq bib (concat bib-before-title bib-title bib-after-title)))))) ; /uncomment title if necessary (insert bib)) (t ; if bib wasn't retrieved successfully (beep) (message "Can't retrieve bibliographic data")))) (t ; if key wasn't retrieved successfully (beep) (message "Can't retrieve key - invalid arxiv number?")))) (beep) (message "Invalid arxiv number")))) (defun hep-th-append-bib (&optional arg) "Append bibliographic data of the paper into bibliography. If ARG is non-nil, prompt for the format. Its the function hep-th-append-bib-internal that really inserts the bibliographic data, which is called internally." (interactive "P") (let (key bib title-start title-end bib-before-title bib-title bib-after-title percent arxiv-number bib-format char) (setq arxiv-number (read-from-minibuffer "Arxiv number (yymm.nnnn or arxiv-name/yymmnnn): " nil nil nil 'hep-th-input-history)) (if arg (setq bib-format (hep-th-read-bib-format)) (setq bib-format hep-th-default-bib-format)) (if (setq arxiv-number (hep-th-arxiv-number-p arxiv-number)) (progn (message "retrieving key..") (setq key (hep-th-arxiv-number-to-key arxiv-number)) (cond (key ; if key is retrieved successfully (message "retrieving bibliographic data..") (setq bib (hep-th-key-to-bib key bib-format)) (cond (bib ; if bib is retrieved successfully ; uncomment title if necessary (cond (hep-th-bib-uncomment-title (setq title-start (string-match "%``" bib)) (setq title-end (string-match "''" bib title-start)) (if (and title-start title-end) (progn (setq title-end (+ title-end 2)) (setq bib-before-title (substring bib 0 title-start) bib-title (substring bib title-start title-end) bib-after-title (substring bib title-end)) (while (setq percent (string-match "%" bib-title)) (setq bib-title (concat (substring bib-title 0 percent) (substring bib-title (+ percent 1))))) (setq bib (concat bib-before-title bib-title bib-after-title)))))) ; /uncomment title if necessary (hep-th-append-bib-internal bib bib-format)) (t ; if bib wasn't retrieved successfully (beep) (message "Can't retrieve bibliographic data")))) (t ; if key wasn't retrieved successfully (beep) (message "Can't retrieve key - invalid arxiv number?")))) (beep) (message "Invalid arxiv number")))) (defun hep-th-append-bib-internal (bib bib-format) "Internal function for hep-th-append-bib. Really append bibliographic data paper into bibliography." (interactive) (let (cite-label (orig-buffer (current-buffer)) cite) (save-excursion (save-window-excursion (cond ; latex or latex2 ((or (equal bib-format 'latex) (equal bib-format 'latex2)) (string-match "\\\\bibitem{\\([^}]+\\)}" bib) ; get cite label (setq cite-label (match-string 1 bib)) ; (beginning-of-buffer) (if (re-search-forward (concat "\\\\bibitem{" cite-label "}") nil t) ; does \bibitem already exist? (progn ; if so, error (message "Bibl. entry \\bibitem{%s} already exists" cite-label) (setq cite (concat "\\cite{" cite-label "}")) ) (beginning-of-buffer) ; if not, append (if (re-search-forward "\\\\end{thebibliography}" nil t) (progn (goto-char (match-beginning 0)) (insert "\n") (insert bib) (insert "\n") (message "Bibl. entry \"%s\" appended to thebibliography environment" cite-label) (setq cite (concat "\\cite{" cite-label "}")) ) (beep) (message "Can't find bibliography environment")))) ; bibtex ((equal bib-format 'bibtex) (string-match "@Article{\\([^,]+\\)[ \t]*," bib) ; get cite label (setq cite-label (match-string 1 bib)) ; (setq bibfile (hep-th-get-bibtex-filename)) (if bibfile ; if bibfile is set (progn (find-file bibfile) (beginning-of-buffer) (if (re-search-forward (concat "@Article{[ \t]*" cite-label "[ \t]*,") nil t) ; does entry already exist? (progn ; if so, error (message "Bibl. entry @Article{%s ..} already exists" cite-label) (setq cite (concat "\\cite{" cite-label "}")) ) (end-of-buffer) ; if not append (beginning-of-line) (if (re-search-forward "[^ \t]$" nil t) ; if the last line is not empty, insert a new line (progn ; for the new entry to be preceded by a new line (end-of-buffer) (insert "\n"))) (insert bib) (insert "\n") (message "Bibl. entry \"%s\" appended to BibTeX file \"%s\"" cite-label bibfile) (setq cite (concat "\\cite{" cite-label "}")) )) ; if bibfile is not set (beep) (message "Can't get BibTeX filename"))) ; harvmac (t (beep) (message "Can't append for %s format" bib-format))) )) (if cite (insert cite)) )) (defun hep-th-spires-query (query-string &optional format sort-by) "Send query to SPIRES HEP. If format or sort-by is nil, substitute them by the default values. If query-string is not a SPIRES HEP command but an arxiv number, convert it into an appropriate SPIRES HEP command." (interactive) (let ((url nil) (arxiv-number (hep-th-arxiv-number-p query-string))) (if (and arxiv-number hep-th-use-arxiv.org-for-arxiv-number) (setq url (concat hep-th-arxiv.org/abs-url "/" arxiv-number)) (setq url (concat hep-th-inspire-hostname "?format=" (if format format hep-th-spires-default-format) "&sequence=" (if sort-by sort-by hep-th-spires-default-sort-by) "&rawcmd=" (hep-th-url-encode (if arxiv-number (concat "f eprint " (hep-th-arxiv-number-p query-string)) query-string))))) (message "browsing %s" url) ; (funcall hep-th-browser-function url) (if (eq hep-th-browser-function 'w3m) (progn (save-excursion (save-window-excursion ))) (funcall hep-th-browser-function url) ))) (defun hep-th-spires-query-from-minibuffer (&optional arg) "Send SPIRES HEP query. Prompt for command. If called with C-u, prompt for FORMAT and SORT-BY." (interactive "P") (let (arxiv-number format sort-by url char) ;query-string (setq query-string (read-from-minibuffer "SPIRES HEP search (command or arxiv number): " nil nil nil 'hep-th-input-history)) (if arg (progn ; format (if (not format) (progn (message (concat "Format: " "0(Default) " "1(Cit.) " "2(Cit. Sum.) " "3(BibTeX) " "4(LaTeX-US) " "5(LaTeX-EU) " "6(Harvmac) " "7(CV) " "8(Brief) " "9(Result Only) " "a(No HTML) " "b(Fermilab)" )) (setq char (read-char) format (cond ((char-equal char ?0) "www") ((char-equal char ?1) "wwwcite") ((char-equal char ?2) "wwwcitesummary") ((char-equal char ?3) "wwwbriefbibtex") ((char-equal char ?4) "wwwbrieflatex") ((char-equal char ?5) "wwwbrieflatex2") ((char-equal char ?6) "wwwbriefharvmac") ((char-equal char ?7) "wwwbrieflatex3") ((char-equal char ?8) "wwwbrief") ((char-equal char ?9) "wwwresult") ((char-equal char ?a) "brief") ((char-equal char ?b) "wwwfnal") (t "www"))))) ; input sort-by (if (not sort-by) (progn (message (concat "Sort-by: " "0(No Sort) " "1(Date-descend) " "2(Date-ascend) " "3(1st Author) " "4(Title) " "5(1st Author,Title)" )) (setq char (read-char) sort-by (cond ((char-equal char ?0) "") ((char-equal char ?1) "ds(d)") ((char-equal char ?2) "ds(a)") ((char-equal char ?3) "AU") ((char-equal char ?4) "T") ((char-equal char ?5) "AU,T") (t ""))))))) (hep-th-spires-query query-string format sort-by))) (defun hep-th-url-encode (string) "URL-encode STRING." (interactive) (let ((pos 0) (quoted-string "") char) (while (< pos (length string)) (setq char (substring string pos (1+ pos))) (setq quoted-string (concat quoted-string (cond ((equal char " ") "+") ((equal char "&") "&") ((equal char "<") "<") ((equal char ">") ">") (t char)))) (setq pos (1+ pos))) quoted-string)) (defun hep-th-get-corresponding-arxiv-number () "Returns the arxiv number at point." (interactive) (let ((current-point (point)) start end line-end arxiv-number keep-going) (save-excursion (end-of-line) (setq line-end (point)) (beginning-of-line) (while (and (re-search-forward "\\(\\([a-zA-Z]+[-\\.][a-zA-Z]+/\\)?[0-9][0-9][0-9][0-9][0-9][0-9][0-9]+\\|[0-9][0-9][0-9][0-9]\\.[0-9][0-9][0-9][0-9]\\)\\([^a-zA-Z0-9]\\|$\\)" nil t) ; search ; arxiv-number can't be followed by a digit or an alphabet. (progn ; if found, (setq start (match-beginning 1) end (match-end 1)) (cond ((and (<= start current-point) ; if cursor is on the arxiv number (< current-point end)) (setq arxiv-number (match-string 1) keep-going nil)) ((< line-end end) ; if beyond the current line, stop search (setq keep-going nil)) (t (setq keep-going t)))))) ; otherwise keep searching arxiv-number))) (defun hep-th-get-corresponding-cite-label (bib-format) "Return the label for citation at point, BIB-FORMAT is 'harvmac, label is of the form \\label. Otherwise, label is of the form \\cite{label}." (interactive) (let ((current-point (point)) line-end label re) (setq bib-format (or bib-format hep-th-default-bib-format)) (if (equal bib-format 'harvmac) (setq re "\\\\\\([a-zA-Z]+\\)") ; label regexp for harvmac (not including the preceding backslash) (setq re "\\\\cite{\\([^}]+\\)}")) ; label regexp for latex, latex2, bibtex (save-excursion (end-of-line) (setq line-end (point)) (beginning-of-line) (while (and (re-search-forward re line-end t) ; pattern found? (if (and (<= (match-beginning 0) current-point) (< current-point (match-end 0))) ; cursor on pattern (progn (setq label (match-string 1)) nil) ; found. return nil to exit (while..) t))) ; not found return t to stay in (while..) label))) (defun hep-th-get-bibtex-filename () "Find BibTeX filename either from the variable hep-th-bibtex-filename or \\bibliography command in the current buffer" (interactive) (let (bibfile) (save-excursion (if hep-th-bibtex-filename (setq bibfile hep-th-bibtex-filename) (progn ; if hep-th-bibfile not set, find bibtex filename from \bibliography (beginning-of-buffer) (if (re-search-forward "\\\\bibliography\\*?{\\([^}]+\\)}" nil t) (setq bibfile (match-string 1))) (if (and bibfile (not (string-match "\\.bib$" bibfile))) ; append ".bib" if there isn't (setq bibfile (concat bibfile ".bib"))))) bibfile))) (defun hep-th-cite-label-to-arxiv-number (cite-label &optional bib-format) "Returns arxiv number corresponding to CITE-LABEL. If hep-th-default-bib-format is 'bibtex, search the BibTeX file designated by \\bibliography command. If hep-th-default-bib-format is othewise, search the current file. If BIB-FORMAT is non-nil, use this in place of hep-th-default-bib-format." (interactive) (let (bibfile arxiv-number current-buf) (setq bib-format (or bib-format hep-th-default-bib-format)) (save-excursion (save-window-excursion (cond ; harvmac ((equal bib-format 'harvmac) (cond ((and (re-search-forward (concat "\\\\lref\\\\" cite-label "{") nil t) (re-search-forward "[^a-zA-Z]\\([a-zA-Z]+[-\\.][a-zA-Z]+/[0-9][0-9][0-9][0-9][0-9][0-9][0-9]\\)" nil t)) (setq arxiv-number (match-string 1))) ; found after point ((and (re-search-backward (concat "\\\\lref\\\\" cite-label "{") nil t) (re-search-forward "[^a-zA-Z]\\([a-zA-Z]+[-\\.][a-zA-Z]+/[0-9][0-9][0-9][0-9][0-9][0-9][0-9]\\)" nil t)) (setq arxiv-number (match-string 1))) ; found before point )) ; bibtex ((equal bib-format 'bibtex) (setq bibfile (hep-th-get-bibtex-filename)) (if bibfile ; if bibfile is set (progn (find-file bibfile) (beginning-of-buffer) (cond ((and (re-search-forward (concat "@Article{[ \t]*" cite-label "[ \t]*,") nil t) (re-search-forward "eprint[ \t]+=[ \t]+\"\\([-a-zA-Z]+/[0-9][0-9][0-9][0-9][0-9][0-9][0-9]\\)\"" nil t)) (setq arxiv-number (match-string 1)))) ; found after point ))) ; latex, latex2 (t (cond ((and (re-search-forward (concat "\\\\bibitem{" cite-label "}") nil t) (re-search-forward "[^a-zA-Z]\\([a-zA-Z]+[-\\.][a-zA-Z]+/[0-9][0-9][0-9][0-9][0-9][0-9][0-9]\\)" nil t)) (setq arxiv-number (match-string 1))) ; found after point ((and (re-search-backward (concat "\\\\bibitem{" cite-label "}") nil t) (re-search-forward "[^a-zA-Z]\\([a-zA-Z]+[-\\.][a-zA-Z]+/[0-9][0-9][0-9][0-9][0-9][0-9][0-9]\\)" nil t)) (setq arxiv-number (match-string 1))) )) ; found before point ) arxiv-number )))) (defun hep-th-browse-corresponding-paper (&optional arg) "Browse the paper of the current position using SPIRES HEP. If the cursor is at an arxiv number, i.e. the letter at the cursor is of the form arxiv-name/yymmnnn, then launch the browser and browse the paper of that arxiv number. If the cursor is on a citation label such as \\cite{Seiberg:1994rs}, then search the bibliography (the \"thebibliography\" environment or if hep-th-default-bib-format is 'bibtex the BibTeX file designated by the \\bibliography command) for the entry, obtain the arxiv number, and launches the browser. If called with with C-u, prompt for the bibliography format and use it in place of hep-th-default-bib-format." (interactive "P") (let (arxiv-number cite-label (bib-format hep-th-default-bib-format)) (if arg (setq bib-format (hep-th-read-bib-format))) (cond ((setq arxiv-number (hep-th-get-corresponding-arxiv-number)) ; if cursor on arxiv number (hep-th-spires-query arxiv-number)) ((setq cite-label (hep-th-get-corresponding-cite-label bib-format)) ; else if cursor on citation label (if (setq arxiv-number (hep-th-cite-label-to-arxiv-number cite-label bib-format)) (hep-th-spires-query arxiv-number) (beep) (message "Can't find arxiv-number corresponding to label"))) (t (beep) (message "No paper information at current position"))))) ;;; ;(defvar mew-header-mode-menu-spec ; '("Mew" ; ["Queue Message" mew-header-make-message t] ; ["Send Message" mew-header-send-message t] ; ["Set cases" mew-draft-set-case t] ; ["Kill Draft" mew-draft-kill t])) ; ;; xemacs ; (add-submenu nil mew-summary-mode-menu-spec) ; (easy-menu-add mew-summary-mode-menu-spec))) ; ;; graphical emacs ;(easy-menu-define ; mew-header-mode-menu ; mew-header-mode-map ; "Menu used in Header mode." ; mew-header-mode-menu-spec) ; ;; temacs ;(easy-menu-define ; mew-header-mode-menu ; mew-header-mode-map ; "Menu used in Header mode." ; mew-header-mode-menu-spec)