Re: org-bibtex manual

2023-07-25 Thread Ihor Radchenko
Ihor Radchenko  writes:

> I should factor out that lambda into a separate readable function name,
> like `org-bibtex-headline-from-title'.

https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=ac0042184

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: org-bibtex manual

2023-07-20 Thread Ypo
No, I mean customizing the generated headline. Instead of just title, to 
be like:


* Author (year) /Title/. Publisher

Bests

El 20/07/2023 a las 21:00, Ihor Radchenko escribió:

Ypo  writes:


Then, is it not possible to customize the entry generated with
org-bibtex-create?

You mean fields?
Everything is defined in `org-bibtex-types', but it is not currently a 
defcustom.

I see no problem adding user types.


Re: org-bibtex manual

2023-07-20 Thread Ihor Radchenko
Ypo  writes:

> Then, is it not possible to customize the entry generated with 
> org-bibtex-create?

You mean fields?
Everything is defined in `org-bibtex-types', but it is not currently a 
defcustom.

I see no problem adding user types.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: org-bibtex manual

2023-07-20 Thread Ypo

Hi Ihor.

Then, is it not possible to customize the entry generated with 
org-bibtex-create?


Bests



>/#+begin_src emacs-lisp/
>/(defun my-org-bibtex-headline-format (entry)/
>/  "Custom function to generate the headline text for org-bibtex-write."/
>/  (let* ((title (cdr (assoc :title entry)))/
>/ (author (cdr (assoc :author entry/
>/    (concat "Mi encabezado personalizado: " title " - " author)))/
>
>/(setq org-bibtex-headline-format #'my-org-bibtex-headline-format)/
>/#+end_src/

This is correct, but this customization only works in
`org-bibtex-write', which works together with `org-bibtex-read-buffer' /
`org-bibtex-read-file'.

`org-bibtex-create' hard-codes heading to be the same with BiBTeX :title
field.

Yes, org-bibtex is not very polished.


Re: org-bibtex manual

2023-07-16 Thread Ihor Radchenko
Ypo  writes:

> And ChatGPT offers me this alternative, which doesn't seem to work (BTW, 
> I am not able to install asoc.el):

You do not need asoc.el.. `assoc' is the built-in function.

> #+begin_src emacs-lisp
> (defun my-org-bibtex-headline-format (entry)
>    "Custom function to generate the headline text for org-bibtex-write."
>    (let* ((title (cdr (assoc :title entry)))
>   (author (cdr (assoc :author entry
>      (concat "Mi encabezado personalizado: " title " - " author)))
>
> (setq org-bibtex-headline-format #'my-org-bibtex-headline-format)
> #+end_src

This is correct, but this customization only works in
`org-bibtex-write', which works together with `org-bibtex-read-buffer' /
`org-bibtex-read-file'.

`org-bibtex-create' hard-codes heading to be the same with BiBTeX :title
field.

Yes, org-bibtex is not very polished.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: org-bibtex manual

2023-07-16 Thread Ihor Radchenko
Ypo  writes:

> I would like to customize the name of the heading. I think it should be 
> customized this function: "Org Bibtex Headline Format Function".
>
> Is there a guide to do this?
>
> I can see the default is:
>
> #[257 "\300.\236A\207"
>    [:title]
>    3 "\n\n(fn ENTRY)"]
>

That's a bit misleading because of compilation.
The original code is

(defcustom org-bibtex-headline-format-function
  (lambda (entry) (cdr (assq :title entry)))
  "Function returning the headline text for `org-bibtex-write'.
It should take a single argument, the bibtex entry (an alist as
returned by `org-bibtex-read').  The default value simply returns
the entry title."
  :group 'org-bibtex
  :version "26.1"
  :package-version '(Org . "9.1")
  :type 'function)

I should factor out that lambda into a separate readable function name,
like `org-bibtex-headline-from-title'.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: org-bibtex manual

2023-07-16 Thread Ypo

Thanks, Ihor.

I would like to customize the name of the heading. I think it should be 
customized this function: "Org Bibtex Headline Format Function".


Is there a guide to do this?

I can see the default is:

#[257 "\300\236A\207"
  [:title]
  3 "\n\n(fn ENTRY)"]


But I don't know how to customize it.

ChatGPT says:

"Unless you are an advanced Emacs Lisp developer and have a specific 
need to work with byte-compiled code, you generally don't need to 
interact with or modify this representation directly. Instead, you can 
work with the function using its regular name and definition."



And ChatGPT offers me this alternative, which doesn't seem to work (BTW, 
I am not able to install asoc.el):


#+begin_src emacs-lisp
(defun my-org-bibtex-headline-format (entry)
  "Custom function to generate the headline text for org-bibtex-write."
  (let* ((title (cdr (assoc :title entry)))
 (author (cdr (assoc :author entry
    (concat "Mi encabezado personalizado: " title " - " author)))

(setq org-bibtex-headline-format #'my-org-bibtex-headline-format)
#+end_src


Best regards


Re: org-bibtex manual

2023-07-16 Thread Ihor Radchenko
Ypo  writes:

> Now... I would like to start using it. I have seen it has a kind of 
> org-capture template (M-x org-bibtex-create-in-current-entry).
>
> If I wanted to add more properties:
>
> - How should the different properties be named and filled to work correctly?

In general, the types of properties are dictated by `org-bibtex-types',
which is declaring Bibtex standards. With C-u argument, you will be
asked for optional properties.

If you want to add non-standard properties, org-set-property will work.

> - Should the names of the properties be exactly like in Bibtex?

Yes. Either exact, or prefixed with `org-bibtex-prefix'. Mixing
with/without prefix will also work.

See also `org-bibtex-export-arbitrary-fields'.

> - Are there any existing org-capture templates with the properties each 
> entry type could have? Or could you advise a manual of bibtex to create 
> myself some complete templates?

You can create a template by adding `org-bibtex-create'
to :hook property of your capture template:

(setq org-capture-templates '(("a" "test" entry (file "/tmp/1.org") "" :hook 
org-bibtex-create)))

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at