jkitchin / org-ref

org-mode modules for citations, cross-references, bibliographies in org-mode and useful bibtex tools to go with it.
GNU General Public License v3.0
1.36k stars 242 forks source link

C-c ] binding changes strangely #603

Closed novusshu closed 3 years ago

novusshu commented 5 years ago

I've encountered a strange behavior with the C-c ] binding.

This is a reproducibel example: I use the defautl completion library, and when I start a new session of emacs, in an file in org-mode, I check C-c ] using C-h c, it shows that

C-c ] runs org-ref-helm-insert-cite-link

Then I use C-h f to query any function in org-ref package, say org-ref. Then I check the binding of C-c ] again, it runs a different function!

C-c ] runs the command org-ref-insert-cite-link

It appears that the first time, it uses a helm-bibtex completion, and the second time reftex completion.

Where goes wrong?

jkitchin commented 5 years ago

C-c ] should always be bound to org-ref-insert-link I think. That command will call the function in the variable org-ref-insert-cite-function.

When you run C-c ] the second time, does it still use helm-bibtex?

Did you set C-c ] manually in your init files to the org-ref-helm-insert-cite-link command?

novusshu commented 5 years ago

I didn't set C-c ] manually in my init. As I said, the first time it uses helm-bibtex interface, and the second time reftex interface.

It seems to me that the C-c ] command calls a different completion backend after I used C-h on org-ref documents.

jkitchin commented 5 years ago

That sounds weird. I haven't been able to reproduce it on my end.

novusshu commented 5 years ago

That is rather strange. I deleted org-ref, started with emacs -q from command line, and then installed org-ref again. And repeated the actions I said in the first post, and I can perfectly reproduce the issue.

My emacs version: 27.0.50 org-ref: org-ref-20180917.2018 OS: macOS High Sirra, 10.13.6

Do you think it could be my system? Or other incompatibilities?

jkitchin commented 5 years ago

Depending on your setup, you might have a stray org-ref in ~/.emacs.d or something. I don't have such a modern emacs to check it on, I still use emacs25, and I only run Sierra 10.12.6. On these, I can't reproduce the issue so far.

novusshu commented 5 years ago

I hardly think so, as there is only one folder containing org-ref in my .emacs.d folder. Anyhow, I'll wait to see if someone else encouters the same issue. Thanks for your help and for this great package!

petemcd18 commented 4 years ago

OK, so I've not used emacs for maybe 3-4 months as I had been away from studying. I installed emacs and my packages a fresh on new ubuntu 19.10 setup and I am experiencing a very odd issue with C-c ] also

I followed this and replicate exactly the same: I've encountered a strange behavior with the C-c ] binding.

This is a reproducible example: I use the default completion library, and when I start a new session of emacs, in an file in org-mode, I check C-c ] using C-h c, it shows that

C-c ] runs org-ref-helm-insert-cite-link

Then I use C-h f to query any function in org-ref package, say org-ref. Then I check the binding of C-c ] again, it runs a different function!

C-c ] runs the command org-ref-insert-cite-link

It appears that the first time, it uses a helm-bibtex completion, and the second time reftex completion.

=====

I should point out that my config uses helm-bibtex and this has never been a problem for me in the past. I'm really not sure what is going wrong but when I try C-c ] Emacs hangs on "Parsing bibliography file "prints location of file" The only way out at this point is for me to use a kill command in terminal to kill emacs as it totally locks up. below is helm bibtex config

  (require 'helm-bibtex)
   (setq bibtex-completion-bibliography
      '("/media/user01/ENCSTICK01/Bibliography/bibliography.bib"))
   (setq bibtex-completion-library-path
   '("/media/user01/ENCSTICK01/Bibliography/pdfs"))
   (setq bibtex-completion-pdf-field "File")
   (setq bibtex-completion-notes-path "/media/user01/ENCSTICK01/Bibliography/notes")
   (setq bibtex-completion-additional-search-fields '(tags))
   (setq bibtex-completion-pdf-symbol "⌘")
   (setq bibtex-completion-notes-symbol "✎")
   (setq bibtex-completion-cite-default-command "footcite")
   (setq org-ref-default-citation-link "footcite")
; Tell org-ref to let helm-bibtex find notes for it
(setq org-ref-notes-function
      (lambda (thekey)
    (let ((bibtex-completion-bibliography (org-ref-find-bibliography)))
      (bibtex-completion-edit-notes
       (list (car (org-ref-get-bibtex-key-and-file thekey)))))))

and below is org-ref config

  (require 'org-ref)
   (require 'org-pdfview)
   (require 'org-ref-pdf)
   (require 'doi-utils)
   (require 'org-ref-url-utils)
   (require 'org-ref-bibtex)
   (require 'org-ref-latex)
   (require 'org-ref-arxiv)
   (require 'org-ref-pubmed)
   (require 'org-ref-isbn)
   (require 'org-ref-wos)
   (require 'org-ref-scopus)
   (require 'org-ref-scifinder)
   (require 'org-ref-worldcat)
   (require 'org-ref-sci-id)
   (require 'ffap)

   ;; Setup org-ref
   (setq reftex-default-bibliography '("/media/user01/ENCSTICK01/Bibliography/bibliography.bib"))
   (setq org-ref-default-bibliography '("/media/user01/ENCSTICK01/Bibliography/bibliography.bib"))
   (setq org-ref-bibliography-notes '("/media/user01/ENCSTICK01/Bibliography/notes"
          org-ref-pdf-directory "/media/user01/ENCSTICK01/Bibliography/pdfs/"))
 (setq org-ref-helm-bibtex-action-preference 'mixed)

I wonder if something has changed in this newer version of org / org-ref which breaks my config?

Note this may not be an Org-Ref issue as I get the same result when I do M-x helm-bibtex

jkitchin commented 4 years ago

I still can't figure out how this could be happening. It doesn't make sense to me that helm-bibtex could be changing a key-binding to an org-ref function

petemcd18 commented 4 years ago

I've done a test with your test files from a git clone of this repo and its working perfectly. I will investigate my config again. I have a feeling one of my oscola specific bibkey types is causing a problem in the bib file. Please ignore John. If I need further assistance I'll ask but it is looking like an issue with my setup. Thanks.

petemcd18 commented 4 years ago

Yes, Sorry John it was my end. My issue is resolved.

guoqinglei commented 3 years ago

I encounter the same problem. I think the cause is related with org-mode-map. But I am not sure what i have done to cause the change of org-mode-map.

However, if I restart the emacs, C-c ] works fine. But I don't know when it will change...

My emacs is 27.1 on mac 10.15

jkitchin commented 3 years ago

my best guess is it is the order that libraries are loaded.