all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Bibtex stuff
@ 2021-10-16 22:15 Emanuel Berg via Users list for the GNU Emacs text editor
  2021-10-16 22:47 ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 4+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-10-16 22:15 UTC (permalink / raw)
  To: help-gnu-emacs; +Cc: emacs-devel

I just refactored my Bibtex stuff in a way that makes sense -
I think. The idea is to split configuration (settings) and
extensions (which is new Lisp code).

The old methods and practices of modularity still apply, of
course ... (ha, that involved, ey? :))

Anyway, the file with the "-incal" suffix is the config!
The rest is not.

all:
  https://dataswamp.org/~incal/emacs-init/bibtex/

files:
  https://dataswamp.org/~incal/emacs-init/bibtex/bibtex-autokey-insert.el
  https://dataswamp.org/~incal/emacs-init/bibtex/bibtex-book.el
  https://dataswamp.org/~incal/emacs-init/bibtex/bibtex-field.el
  https://dataswamp.org/~incal/emacs-init/bibtex/bibtex-incal.el
  https://dataswamp.org/~incal/emacs-init/bibtex/bibtex-next-volume.el

So now anyone can check out the extensions and not be
bothered with mere config!

I realize very few people care for Bibtex but I post it
because one, I might be wrong; and two, I think this
modularity idea is good to make more pleasant the
"Elisp interchange" between Elispers, if you will.

In this case, the bibtex-field stuff is probably such a thing
that ought to be pretty much a basic building block of any such
mode ... not necessarily the exact way I wrote it tho.

BTW I already did this to my ERC and Emacs-w3m stuff, and more
stuff to come Gw ...

  https://dataswamp.org/~incal/emacs-init/erc/
  https://dataswamp.org/~incal/emacs-init/w3m/

Keep it real time ...

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: Bibtex stuff
  2021-10-16 22:15 Bibtex stuff Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-10-16 22:47 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-10-16 22:57   ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 4+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-10-16 22:47 UTC (permalink / raw)
  To: help-gnu-emacs; +Cc: emacs-devel

> In this case, the bibtex-field stuff is probably such
> a thing that ought to be pretty much a basic building block
> of any such mode ... not necessarily the exact way I wrote
> it tho.

Oh, someone has added a `bibtex-next-field'! Great work!
Shouldn't BEGIN be default tho? Other than that I wonder what
the difference is between that and mine ...

Anyway so then add a modified version of my "-prev-" as well
then ;)

Awesome stuff :)

From /usr/local/share/emacs/29.0.50/lisp/textmodes/bibtex.el

(defun bibtex-next-field (begin &optional comma)
  "Move point to end of text of next BibTeX field or entry head.
With prefix BEGIN non-nil, move point to its beginning.  Optional arg COMMA
is as in `bibtex-enclosing-field'.  It is t for interactive calls."
  (interactive (list current-prefix-arg t))
  (let ((bounds (bibtex-find-text-internal t nil comma))
        end-of-entry)
    (if (not bounds)
        (setq end-of-entry t)
      (goto-char (nth 3 bounds))
      (if (assoc-string (car bounds) '("@String" "@Preamble") t)
          (setq end-of-entry t)
        ;; BibTeX key or field
        (if (looking-at ",[ \t\n]*") (goto-char (match-end 0)))
        ;; end of entry
        (if (looking-at "[)}][ \t\n]*") (setq end-of-entry t))))
    (if (and end-of-entry
             (re-search-forward bibtex-any-entry-maybe-empty-head nil t))
      (goto-char (match-beginning 0)))
    (bibtex-find-text begin nil bibtex-help-message)))

My file:

;;; -*- lexical-binding: t -*-
;;;
;;; this file:
;;;   https://dataswamp.org/~incal/emacs-init/bibtex/bibtex-field.el
;;;
;;; test here:
;;;   https://dataswamp.org/~incal/books/books.bib

(require 'cl-lib)

(defun bibtex-prev-field ()
  (interactive)
  (cl-labels ((search-prev ()
                (when (re-search-backward "=\\|@" nil t)
                  (let ((eol (line-end-position)))
                    (unless (re-search-forward "{" eol t)
                      (forward-char 2) )))
                (point) ))
    (when (= (point) (search-prev))
      (let ((beg (point)))
        (beginning-of-line)
        (when (= (point) (search-prev))
          (goto-char beg) )))))

(defun re-search-forward-return (regexp)
  (save-excursion
    (re-search-forward regexp (point-max) t) ))

(defun bibtex-beginning-of-next-field ()
  (interactive)
  (cl-labels ((advance (to)
                 (goto-char to)
                 (if (looking-at "[[:space:]]*{")
                     (goto-char (match-end 0))
                   (forward-char 1) )))
    (let*((next-curly (re-search-forward-return "{"))
          (next-equal (re-search-forward-return "=")) )
      (if (and next-curly next-equal)
          (if (< next-curly next-equal)
              (goto-char next-curly)
            (advance next-equal) )
        (if next-equal
            (advance next-equal)
          (when next-curly
            (goto-char next-curly) ))))))

(provide 'bibtex-field)


-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: Bibtex stuff
  2021-10-16 22:47 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-10-16 22:57   ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-10-17  1:37     ` weird key message (was: Re: Bibtex stuff) Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 4+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-10-16 22:57 UTC (permalink / raw)
  To: help-gnu-emacs; +Cc: emacs-devel

> From /usr/local/share/emacs/29.0.50/lisp/textmodes/bibtex.el
>
> (defun bibtex-next-field (begin &optional comma)
>         [...]
>         (if (looking-at ",[ \t\n]*") (goto-char (match-end 0)))

(when (looking-at ",[ \t\n]*")
  (goto-char (match-end 0)) )

>         ;; end of entry
>         (if (looking-at "[)}][ \t\n]*") (setq end-of-entry t))))

Same (`when').

Perhaps [:space:] can be used as well?

-- 
underground experts united
https://dataswamp.org/~incal




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

* weird key message (was: Re: Bibtex stuff)
  2021-10-16 22:57   ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-10-17  1:37     ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 4+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-10-17  1:37 UTC (permalink / raw)
  To: help-gnu-emacs; +Cc: emacs-devel

I set out to try this `bibtex-next-field', and it seems to
work great! So I'll remove mine, I think ...

I'll keep the "-prev-" one tho, which is a bit backwards (ha)
since if there is a next in the vanilla, shouldn't there be
a prev as well? Like symmetry or something?

Anyway what I wanted to ask was, what I did was, I changed the
keybinding from mine to the builtin, so it now looks  like
this

(defun set-biblatex-keys ()
  (let ((the-map bibtex-mode-map))
    (define-key the-map  [backtab] #'bibtex-prev-field)
    (define-key the-map "\t"       (lambda () (interactive) (bibtex-next-field t)))
    ;; ...
    ))

then

;; (setq bibtex-mode-hook nil)
(defun bibtex-mode-hook-f ()
  ;; ...
  (set-biblatex-keys) )
(add-hook 'bibtex-mode-hook #'bibtex-mode-hook-f)

It works great only when I do `C-h k TAB' it says all this!
Somethings up, right?

TAB runs the command (closure ((the-map keymap (backtab .
bibtex-prev-field) (15) (S-caps) (12) (menu-bar keymap
(biblatex menu-item "Entry-Types" (keymap (bibtex-Article
menu-item "Article in Journal" bibtex-Article) (bibtex-Book
menu-item "Single-Volume Book" bibtex-Book) (bibtex-MVBook
menu-item "Multi-Volume Book" bibtex-MVBook) (bibtex-InBook
menu-item "Chapter or Pages in a Book" bibtex-InBook)
(bibtex-BookInBook menu-item "Book in Collection"
bibtex-BookInBook) (bibtex-SuppBook menu-item "Supplemental
Material in a Book" bibtex-SuppBook) (bibtex-Booklet menu-item
"Booklet (Bound, but no Publisher)" bibtex-Booklet)
(bibtex-Collection menu-item "Single-Volume Collection"
bibtex-Collection) (bibtex-MVCollection menu-item
"Multi-Volume Collection" bibtex-MVCollection)
(bibtex-InCollection menu-item "Article in a Collection"
bibtex-InCollection) (bibtex-SuppCollection menu-item
"Supplemental Material in a Collection" bibtex-SuppCollection)
(bibtex-Dataset menu-item "Data Set" bibtex-Dataset)
(bibtex-Manual menu-item "Technical Manual" bibtex-Manual)
(bibtex-Misc menu-item "Miscellaneous" bibtex-Misc)
(bibtex-Online menu-item "Online Resource" bibtex-Online)
(bibtex-Patent menu-item "Patent" bibtex-Patent)
(bibtex-Periodical menu-item "Complete Issue of a Periodical"
bibtex-Periodical) (bibtex-SuppPeriodical menu-item
"Supplemental Material in a Periodical" bibtex-SuppPeriodical)
(bibtex-Proceedings menu-item "Single-Volume Conference
Proceedings" bibtex-Proceedings) (bibtex-MVProceedings
menu-item "Multi-Volume Conference Proceedings"
bibtex-MVProceedings) (bibtex-InProceedings menu-item "Article
in Conference Proceedings" bibtex-InProceedings)
(bibtex-Reference menu-item "Single-Volume Work of Reference"
bibtex-Reference) (bibtex-MVReference menu-item "Multi-Volume
Work of Reference" bibtex-MVReference) (bibtex-InReference
menu-item "Article in a Work of Reference" bibtex-InReference)
(bibtex-Report menu-item "Technical or Research Report"
bibtex-Report) (bibtex-Software menu-item "Computer Software"
bibtex-Software) (bibtex-Thesis menu-item "PhD or Master's
Thesis" bibtex-Thesis) (bibtex-Unpublished menu-item
"Unpublished" bibtex-Unpublished) (nil-1 menu-item "--")
(bibtex-String menu-item "String" bibtex-String)
(bibtex-preamble menu-item "Preamble" bibtex-Preamble) (nil-2
menu-item "--") (select menu-item "BibTeX dialect" (keymap
(BibTeX menu-item "BibTeX" (lambda nil (interactive)
(bibtex-set-dialect 'BibTeX t)) :button (:radio eq
bibtex-dialect 'BibTeX)) (biblatex menu-item "biblatex"
(lambda nil (interactive) (bibtex-set-dialect 'biblatex t))
:button (:radio eq bibtex-dialect 'biblatex))))) :visible (eq
bibtex-dialect 'biblatex)) (BibTeX menu-item "Entry-Types"
(keymap (bibtex-Article menu-item "Article in Journal"
bibtex-Article) (bibtex-InProceedings menu-item "Article in
Conference Proceedings" bibtex-InProceedings)
(bibtex-Conference menu-item "Article in Conference
Proceedings" bibtex-Conference) (bibtex-InCollection menu-item
"Article in a Collection" bibtex-InCollection) (bibtex-InBook
menu-item "Chapter or Pages in a Book" bibtex-InBook)
(bibtex-Proceedings menu-item "Conference Proceedings"
bibtex-Proceedings) (bibtex-Book menu-item "Book" bibtex-Book)
(bibtex-Booklet menu-item "Booklet (Bound, but no Publisher)"
bibtex-Booklet) (bibtex-PhdThesis menu-item "PhD Thesis"
bibtex-PhdThesis) (bibtex-MastersThesis menu-item "Master's
Thesis" bibtex-MastersThesis) (bibtex-TechReport menu-item
"Technical Report" bibtex-TechReport) (bibtex-Manual menu-item
"Technical Manual" bibtex-Manual) (bibtex-Unpublished
menu-item "Unpublished" bibtex-Unpublished) (bibtex-Misc
menu-item "Miscellaneous" bibtex-Misc) (nil-1 menu-item "--")
(bibtex-String menu-item "String" bibtex-String)
(bibtex-preamble menu-item "Preamble" bibtex-Preamble) (nil-2
menu-item "--") (select menu-item "BibTeX dialect" (keymap
(BibTeX menu-item "BibTeX" (lambda nil (interactive)
(bibtex-set-dialect 'BibTeX t)) :button (:radio eq
bibtex-dialect 'BibTeX)) (biblatex menu-item "biblatex"
(lambda nil (interactive) (bibtex-set-dialect 'biblatex t))
:button (:radio eq bibtex-dialect 'biblatex))))) :visible (eq
bibtex-dialect 'BibTeX)) (bibtex-edit menu-item "BibTeX-Edit"
(keymap "BibTeX-Edit" (Moving\ inside\ an\ Entry menu-item
"Moving inside an Entry" (keymap "Moving inside an Entry"
(End\ of\ Field menu-item "End of Field" bibtex-find-text)
(Next\ Field menu-item "Next Field" bibtex-next-field) (Next\
entry menu-item "Next entry" bibtex-next-entry) (Previous\
entry menu-item "Previous entry" bibtex-previous-entry)
(Beginning\ of\ Entry menu-item "Beginning of Entry"
bibtex-beginning-of-entry) (End\ of\ Entry menu-item "End of
Entry" bibtex-end-of-entry) (nil menu-item "--") (Make\ Entry\
Visible menu-item "Make Entry Visible"
bibtex-reposition-window))) (Moving\ in\ BibTeX\ Buffers
menu-item "Moving in BibTeX Buffers" (keymap "Moving in BibTeX
Buffers" (Search\ Entry menu-item "Search Entry"
bibtex-search-entry) (Search\ Crossref\ Entry menu-item
"Search Crossref Entry" bibtex-search-crossref))) (nil
menu-item "--") (Operating\ on\ Current\ Field menu-item
"Operating on Current Field" (keymap "Operating on Current
Field" (Fill\ Field menu-item "Fill Field" fill-paragraph)
(Remove\ Delimiters menu-item "Remove Delimiters"
bibtex-remove-delimiters) (Remove\ OPT\ or\ ALT\ Prefix
menu-item "Remove OPT or ALT Prefix" bibtex-remove-OPT-or-ALT)
(Clear\ Field menu-item "Clear Field" bibtex-empty-field) (nil
menu-item "--") (Kill\ Field menu-item "Kill Field"
bibtex-kill-field) (Copy\ Field\ to\ Kill\ Ring menu-item
"Copy Field to Kill Ring" bibtex-copy-field-as-kill) (Paste\
Most\ Recently\ Killed\ Field menu-item "Paste Most Recently
Killed Field" bibtex-yank) (Paste\ Previously\ Killed\ Field
menu-item "Paste Previously Killed Field" bibtex-yank-pop)
(nil-9 menu-item "--") (Make\ New\ Field menu-item "Make New
Field" bibtex-make-field) (nil-11 menu-item "--") (Snatch\
from\ Similar\ Following\ Field menu-item "Snatch from Similar
Following Field" bibtex-pop-next) (Snatch\ from\ Similar\
Preceding\ Field menu-item "Snatch from Similar Preceding
Field" bibtex-pop-previous) (nil-14 menu-item "--") (String\
or\ Key\ Complete menu-item "String or Key Complete"
bibtex-complete) (nil-16 menu-item "--") (Help\ about\
Current\ Field menu-item "Help about Current Field"
bibtex-print-help-message))) (Operating\ on\ Current\ Entry
menu-item "Operating on Current Entry" (keymap "Operating on
Current Entry" (Fill\ Entry menu-item "Fill Entry"
bibtex-fill-entry) (Clean\ Entry menu-item "Clean Entry"
bibtex-clean-entry) (Update\ Entry menu-item "Update Entry"
bibtex-entry-update) (nil menu-item "--") (Kill\ Entry
menu-item "Kill Entry" bibtex-kill-entry) (Copy\ Entry\ to\
Kill\ Ring menu-item "Copy Entry to Kill Ring"
bibtex-copy-entry-as-kill) (Paste\ Most\ Recently\ Killed\
Entry menu-item "Paste Most Recently Killed Entry"
bibtex-yank) (Paste\ Previously\ Killed\ Entry menu-item
"Paste Previously Killed Entry" bibtex-yank-pop) (nil-8
menu-item "--") (Copy\ Summary\ to\ Kill\ Ring menu-item "Copy
Summary to Kill Ring" bibtex-copy-summary-as-kill) (Browse\
URL menu-item "Browse URL" bibtex-url) (nil-11 menu-item "--")
(Ispell\ Entry menu-item "Ispell Entry" bibtex-ispell-entry)
(Ispell\ Entry\ Abstract menu-item "Ispell Entry Abstract"
bibtex-ispell-abstract) (nil-14 menu-item "--") (Narrow\ to\
Entry menu-item "Narrow to Entry" bibtex-narrow-to-entry)
(Mark\ Entry menu-item "Mark Entry" bibtex-mark-entry) (nil-17
menu-item "--") (View\ Cite\ Locations\ \(RefTeX\) menu-item
"View Cite Locations (RefTeX)"
reftex-view-crossref-from-bibtex :enable (fboundp
'reftex-view-crossref-from-bibtex)))) (Operating\ on\ Buffer\
or\ Region menu-item "Operating on Buffer or Region" (keymap
"Operating on Buffer or Region" (Search\ Entries menu-item
"Search Entries" bibtex-search-entries) (nil menu-item "--")
(Validate\ Entries menu-item "Validate Entries"
bibtex-validate) (Sort\ Entries menu-item "Sort Entries"
bibtex-sort-buffer) (Reformat\ Entries menu-item "Reformat
Entries" bibtex-reformat) (Count\ Entries menu-item "Count
Entries" bibtex-count-entries) (nil-6 menu-item "--")
(Convert\ Alien\ Buffer menu-item "Convert Alien Buffer"
bibtex-convert-alien))) (Operating\ on\ Multiple\ Buffers
menu-item "Operating on Multiple Buffers" (keymap "Operating
on Multiple Buffers" (\(Re\)Initialize\ BibTeX\ Buffers
menu-item "(Re)Initialize BibTeX Buffers" bibtex-initialize)
(Validate\ Entries menu-item "Validate Entries"
bibtex-validate-globally)))))) (3 keymap (5 keymap (21 .
bibtex-Unpublished) (20 . bibtex-TechReport) (19 .
bibtex-String) (27 keymap (112 . bibtex-Preamble)) (80 .
bibtex-PhdThesis) (112 . bibtex-Proceedings) (16 .
bibtex-InProceedings) (77 . bibtex-Misc) (109 .
bibtex-MastersThesis) (13 . bibtex-Manual) (3 .
bibtex-InCollection) (66 . bibtex-Booklet) (98 . bibtex-Book)
(2 . bibtex-InBook) (1 . bibtex-Article) (73 . bibtex-InBook)
(105 . bibtex-InCollection) (9 . bibtex-InProceedings)) (15 .
bibtex-remove-OPT-or-ALT) (1 . bibtex-search-entries) (12 .
bibtex-url) (18 keymap (119 . widen) (110 .
bibtex-narrow-to-entry)) (2 . bibtex-entry) (36 .
bibtex-ispell-abstract) (21 . bibtex-entry-update) (6 .
bibtex-make-field) (4 . bibtex-empty-field) (25 . bibtex-yank)
(23 . bibtex-kill-entry) (27 keymap (121 . bibtex-yank-pop)
(119 . bibtex-copy-entry-as-kill) (107 .
bibtex-copy-field-as-kill)) (11 . bibtex-kill-field) (14 .
bibtex-pop-next) (16 . bibtex-pop-previous) (63 .
bibtex-print-help-message) (20 . bibtex-copy-summary-as-kill)
(24 . bibtex-search-crossref) (19 . bibtex-search-entry) (17 .
bibtex-fill-entry) (3 . validate-compile-count) (125 .
bibtex-remove-delimiters) (123 . bibtex-remove-delimiters) (34
. bibtex-remove-delimiters)) (27 keymap (110 .
bibtex-autokey-insert-check-isbn) (16 . bibtex-previous-entry)
(14 . bibtex-next-entry) (10) (105) (107) (73) (75) (111)
(112) (13) (97) (65) (8 . bibtex-mark-entry) (12) (5 .
bibtex-end-of-entry) (1 . bibtex-beginning-of-entry) (9 .
completion-at-point)) (remap keymap (backward-paragraph .
bibtex-previous-entry) (forward-paragraph .
bibtex-next-entry)) (10) (9 closure #1 nil (interactive)
(bibtex-next-field t))) t) nil (interactive)
(bibtex-next-field t)) (found in bibtex-mode-map), which is an
interactive Lisp closure.

It is bound to TAB.

(anonymous)

Not documented.

[back]

-- 
underground experts united
https://dataswamp.org/~incal




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

end of thread, other threads:[~2021-10-17  1:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-16 22:15 Bibtex stuff Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-16 22:47 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-16 22:57   ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-17  1:37     ` weird key message (was: Re: Bibtex stuff) Emanuel Berg via Users list for the GNU Emacs text editor

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.