all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Bibtex extract entries for year, title and author
@ 2007-09-25  0:06 Fabian Braennstroem
  2007-09-25  7:17 ` Fabian Braennstroem
  2007-09-26 15:40 ` Roland Winkler
  0 siblings, 2 replies; 4+ messages in thread
From: Fabian Braennstroem @ 2007-09-25  0:06 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

I would like to extract the values of the last entry of
year, title and author.
Did anyone try to do something similar yet and can give an
advice how to do it using emacs-lisp?
Regards!
Fabian

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

* Re: Bibtex extract entries for year, title and author
  2007-09-25  0:06 Bibtex extract entries for year, title and author Fabian Braennstroem
@ 2007-09-25  7:17 ` Fabian Braennstroem
  2007-09-26 15:40 ` Roland Winkler
  1 sibling, 0 replies; 4+ messages in thread
From: Fabian Braennstroem @ 2007-09-25  7:17 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

Fabian Braennstroem schrieb am 09/25/2007 12:06 AM:
> Hi,
> 
> I would like to extract the values of the last entry of
> year, title and author.
> Did anyone try to do something similar yet and can give an
> advice how to do it using emacs-lisp?

Maybe, not everybody knows the structure of bibtex files....

@Article{chroneer99:_accur_of_flow_simul_of,
  author = 	 {A. Author},
  title = 	 {T {T}itle},
  journal = 	 {SAE},
  year = 	 1999,
  key = 	 {1999-01-1201},
  pages = 	 {1-11}}


@PhdThesis{kriegel05:_exper_unter_und_numer_simul_eines_quell,
  author = 	 {M. Last Author},
  title = 	 {Last Title},
  school = 	 {Berlin},
  year = 	 2005,
  key = 	 {D 83},
  note = 	 {test}}

Greetings!
Fabian

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

* Re: Bibtex extract entries for year, title and author
  2007-09-25  0:06 Bibtex extract entries for year, title and author Fabian Braennstroem
  2007-09-25  7:17 ` Fabian Braennstroem
@ 2007-09-26 15:40 ` Roland Winkler
  2007-09-26 21:26   ` Fabian Braennstroem
  1 sibling, 1 reply; 4+ messages in thread
From: Roland Winkler @ 2007-09-26 15:40 UTC (permalink / raw)
  To: help-gnu-emacs

Fabian Braennstroem <f.braennstroem@gmx.de> writes:
> I would like to extract the values of the last entry of year,
> title and author. Did anyone try to do something similar yet and
> can give an advice how to do it using emacs-lisp?

What do you mean by "last entry"? In Emacs 22, there is
bibtex-copy-summary-as-kill (bound to C-c C-t in BibTeX mode) which
can be adapted to your needs with respect to the fields it uses
(though not customizable in the proper sense). Does it do what you
have in mind?

Roland

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

* Re: Bibtex extract entries for year, title and author
  2007-09-26 15:40 ` Roland Winkler
@ 2007-09-26 21:26   ` Fabian Braennstroem
  0 siblings, 0 replies; 4+ messages in thread
From: Fabian Braennstroem @ 2007-09-26 21:26 UTC (permalink / raw)
  To: help-gnu-emacs

Hi Roland

Roland Winkler schrieb am 09/26/2007 03:40 PM:
> Fabian Braennstroem <f.braennstroem@gmx.de> writes:
>> I would like to extract the values of the last entry of year,
>> title and author. Did anyone try to do something similar yet and
>> can give an advice how to do it using emacs-lisp?
> 
> What do you mean by "last entry"? In Emacs 22, there is
> bibtex-copy-summary-as-kill (bound to C-c C-t in BibTeX mode) which
> can be adapted to your needs with respect to the fields it uses
> (though not customizable in the proper sense). Does it do what you
> have in mind?

Thanks for your help!  I actually want to manage all my
electronic literature using emacs bibtex-mode. Therefore I
needed to know the last entries I just wrote; I could achive
it using the cleaning function from bibtex-mode.
I have now some 'working' code which renames and moves the
pdf file according to the bibtex-entry into the appropriate
directory and category.

These steps are needed to use the below stuff:
a) in a dired buffer run 'bibtex_pfm'
b) choose a category.bib file (bibtex-mode)
c) insert an entry
d) run 'bibtex-my-clean-entry

The managing does not work with doc-view somehow... so I use
an external xpdf. And the window splitting could work a bit
better... The ascii pdf view and the shortcuts.bib are just
some helping buffers, e.g. for copying long titles...

; Bibtex-Manage
;**************************************************************************************************************
(require 'doc-view)
(defun bibtex_pfm()
    "Runs PFM_BIBTEX"
    (interactive)
    (setq filename (dired-get-filename))
    (delete-other-windows)
    (call-process "xpdf" nil 0 nil (dired-get-filename)  )
    ;(doc-view-dired t) ; Open PDF
    (split-window-horizontally)
    (find-file filename) ; Open PDF as ascii
    (split-window-vertically)
    (find-file "~/BibTeX/shortcuts.bib")
    (split-window-vertically)
    (find-file "~/BibTeX/")
)


(defun rename-file-and-buffer (new-name)
 "Renames both current buffer and file it's visiting to
NEW-NAME." (interactive "sNew name: ")
 (let ((name (buffer-name))
	(filename (buffer-file-name)))
 (if (not filename)
	(message "Buffer '%s' is not visiting a file!" name)
 (if (get-buffer new-name)
	 (message "A buffer named '%s' already exists!" new-name)
	(progn 	 (rename-file name new-name 1) 	 (rename-buffer
new-name) 	 (set-visited-file-name new-name) 	
(set-buffer-modified-p nil)))))) ;;

(defun bibtex-my-clean-entry (&optional new-key
called-by-reformat)
  "Finish editing the current BibTeX entry and clean it up.
Check that no required fields are empty and formats entry
dependent
on the value of `bibtex-entry-format'.
If the reference key of the entry is empty or a prefix
argument is given,
calculate a new reference key.  (Note: this works only if
fields in entry
begin on separate lines prior to calling
`bibtex-clean-entry' or if
'realign is contained in `bibtex-entry-format'.)
Don't call `bibtex-clean-entry' on @Preamble entries.
At end of the cleaning process, the functions in
`bibtex-clean-entry-hook' are called with region narrowed to
entry."
  ;; Opt. arg called-by-reformat is t if bibtex-clean-entry
  ;; is called by bibtex-reformat
  (interactive "P")
  (let ((case-fold-search t)
        (start (bibtex-beginning-of-entry))
        (_ (or (looking-at bibtex-any-entry-maybe-empty-head)
	       (error "Not inside a BibTeX entry")))
        (entry-type (bibtex-type-in-head))
        (key (bibtex-key-in-head)))
    ;; formatting
    (cond ((bibtex-string= entry-type "preamble")
           ;; (bibtex-format-preamble)
           (error "No clean up of @Preamble entries"))
          ((bibtex-string= entry-type "string")
           (setq entry-type 'string))
          ;; (bibtex-format-string)
          (t (bibtex-format-entry)))
    ;; set key
    (when (or new-key (not key))
      (setq key (bibtex-generate-autokey))
      ;; Sometimes bibtex-generate-autokey returns an empty
string
      (if (or bibtex-autokey-edit-before-use (string= "" key))
          (setq key (if (eq entry-type 'string)
                        (bibtex-read-string-key key)
                      (bibtex-read-key "New Filename: " key))))
      (message "New Filename: %s" key))

; orig. bibtex-clean-entry
(bibtex-clean-entry)

(save-buffer)

(setq category (file-name-sans-extension
(file-name-nondirectory buffer-file-name)))
(other-window 1)
(other-window 1)
(setq new_name (concat "~/BibTeX/" category "/" key ".pdf"))
(message "New FILENAME: %s" new_name)
(rename-file-and-buffer new_name)
(dired-jump)
(delete-other-windows)
(split-window-horizontally)
))


;
shortcuts.bib---------------------------------------------------------------------
@string{theor = "Theoretical and Computational Fluid Dynamics"}
@string{nhtb = "Numerical Heat Transfer. Part B"}
@string{nhta = "Numerical Heat Transfer. Part A"}
@string{arfm = "Annual Review of Fluid Mechanics"}
@string{arfms = "Ann. Rev. Fluid Mech."}
@string{jfm = "Journal of Fluid Mechanics"}
@string{jfms = "J. Fluid Mech."}
@string{ihmt = "International Journal of Heat and Mass
Transfer"}
@string{ijnmf = "International Journal for Numerical Methods
in Fluids"}
@string{ihmts = "Int. J. Heat Mass Transfer"}

;~/BibTeX/:-----------------------------------------
/Category1
/Category2
Category1.bib
Category2.bib



Greetings!
Fabian

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

end of thread, other threads:[~2007-09-26 21:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-25  0:06 Bibtex extract entries for year, title and author Fabian Braennstroem
2007-09-25  7:17 ` Fabian Braennstroem
2007-09-26 15:40 ` Roland Winkler
2007-09-26 21:26   ` Fabian Braennstroem

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.