Comments (21)
Deleting the URL doesn't change anything.
Adding the dummy parameter "fixes" it, simply because I then use the eval'd version instead of the byte compiled one.
Byte compiling yields no warning or whatever.
Maybe it's something with cl-defun?
It looks like an Emacs bug to me. The hard way to check would be to rewrite the package without cl-defun
and test it. I have no time for this the next days, however, and I am not suggesting you should do it.
But you should be able to reproduce the error:
- open emacs
- set the
.bib
file above as bibliography file for bibtex-completion bibtex-actions-refresh
- select "jörissen"
- nil nil
- go to the source
- re-eval
bibtex-actions-read
- select "jörissen" again
- it works
- reload the compiled version
(load-library "bibtex-actions")
- and back to 2.
I will try to reproduce the error with a clean version (-q) and report the results. Might take a while, though.
from citar.
Declaring the variable fixes the issue. And it makes sense, since it is an issue with byte compilation, and that's the only thing changed by that declaration. I made a PR.
from citar.
@bdarcus Indeed, there is no warning in this case. The problem is that you used when-let
here, which is not a good idea. when-let
automatically uses the lexically bound variables since it expands to let+when. I suggest you only use when-let
in case it is necessary to check the value.
from citar.
So my guess is that the problem has to do with compilation.
But no errors upon such compilation; right?
In the past, I sometimes have run into errors like that which comes down to the way completing-read-multiple
parses candidates (it gets confused by trailing whitespace, and punctuation can throw it off, which is why the ampersand is the delimiter).
from citar.
from citar.
from citar.
from citar.
It looks like an Emacs bug to me.
Sure sounds like it.
I will try to reproduce the error with a clean version (-q) and report the results. Might take a while, though.
Thank you!
from citar.
It's the comma!
I was able to reproduce the error with a clean setup. I finally found the error: It's the "," in the title field. It makes completion-read-multiple
think that I have entered multiple items, whereas in reality, I have not. Stupid little Emacs. I have no idea why the error goes away once I eval the defun directly (this behavior too was reproducible).
Here's what I did for debugging:
;; start with emacs -q -l 'filenameofthatsnippet.el'
(require 'package)
(package-initialize)
(require 'use-package)
(require 'quelpa-use-package)
(setq visible-bell nil
ring-bell-function 'ignore)
(use-package bibtex-completion
:config
(setq bibtex-completion-bibliography '("~/bibfile_causing_nil.bib"))
(setq bibtex-completion-notes-path "~/Dokumente/Hefte/zettelkasten"))
(use-package bibtex-actions
:bind
(("C-x l" . bibtex-actions-open-notes)))
And I added some debug vars to bibtex-actions-read:
(when-let ((crm-separator "\\s-*&\\s-*")
(candidates (setq bibtex-actions--debug-candidates (bibtex-actions--get-candidates rebuild-cache)))
(chosen
(setq bibtex-actions--debug-chosen
(completing-read-multiple ......
Using this setup, I could provoke the error and look at the variables. If I choose the first title with the comma, bibtex-actions--debug-chosen
is a list of two strings. This causes the cl-loop
clause to produce (nil nil)
. If I choose the second title, it is a list with only one string -- the expected behavior.
from citar.
Yeah, why I mentioned the CRM issue above and asked about the URL field, which has an &
.
When you realize the CRM selections are one string, you can see how it can be brittle in certain circumstances.
But I don't see why the comma is a problem, given the crm-separator
is the ampersand?
Indeed, @oantolin suggested the ampersand precisely to avoid that problem with these data (because you have to escape it in tex).
Is there something subtle wrong with that regexp, or with how I'm setting the local variable? E.g. is &
not in fact being used as the crm-separator
??
from citar.
The default value of crm-separator
is "[ ]*,[ ]*"
. So it looks like the when-let
doesn't override it. But I just caught the value of crm-separator
in a global debug variable, like with the other let-bound values above, and it returned the modfied string with the ampersand. So it is overriden in this scope.
I can't explain it, but I have the feeling that somewhere in the depths of completions-read-multiple
, something relies on dynamic scoping, or for some other reasons accesses the default instead of the overriden value. Which is why it works when I eval it manually in the file.
from citar.
Well, at least the source file for completing-read-multiple
has no lexical scoping declaration in its top.
from citar.
@oantolin @minad - do you have any insight into what @publicimageltd is hypothesizing just above here? Is this a crm bug? Something wrong with this code??
from citar.
Debugging in real time: If I set the variable crm-separator
explicitly to the ampersand regexp usingdefvar
, it works. So the problem is indeed that completing-read-multiple
accesses the dynamically bound value for crm-separator,
whereas bibtex-actions-read
uses lexical-binding: t
.
Problem being, of course, that using defvar,
the global default is changed. But there must be a way to set a variably dynamically within a file with lexical binding enabled... or? And I vaguely remember having read that in Emacs 28, all files have be changed to use lexical binding.
from citar.
@bdarcus @publicimageltd Yes this can be. Are you requiring 'crm? Then you should get the defvar which makes the variable dynamically bound. Otherwise you can write a defvar declaration yourself, (defvar crm-separator)
. My recommendation is to use package-lint in combination with flycheck or flymake to catch many of such issues early on. In this case it would probably warn that crm-separator
is lexically bound but unused.
from citar.
I originally did that, but didn't understand why.
But when it went through the review at MELPA, they recommended removing it.
I'll add it back then.
So am I adding that specific crm-separator as a defvar at the top, and removing the let-bound one on the function, or am I only setting the defvar to nil (this is what I originally did).
from citar.
Any chance you want to submit a PR @publicimageltd?
from citar.
On this, @minad @publicimageltd:
My recommendation is to use package-lint in combination with flycheck or flymake to catch many of such issues early on. In this case it would probably warn that
crm-separator
is lexically bound but unused.
- I use doom emacs for elisp coding, which has all this setup, and does flag these sorts of warnings and errors for me. No such warnings or errors ATM.
- I have the elisp-check github action setup, which does the same checks, and flags unused lexical variables on PRs. I have a policy, for myself as well, of never merging a PR with even a warning.
- I haven't seen this bug, and @publicimageltd only sees is when he uses the byte-compiled package.
These three facts don't add up for me. Do they for you two?
from citar.
@publicimageltd - #23 is the original PR I merged that I thought fixed the problem, and later removed.
from citar.
3. I haven't seen this bug, and @publicimageltd only sees is when he uses the byte-compiled package.
Which Emacs version do you use? If it's a greater (how do you say? bigger?) version than 27.2, have a look at the source file for crm
, and if it has a lexical binding declaration on the first line. As I said, I have read somewhere on emacs devel that all files have been converted to lexical binding lately for some more recent version of Emacs.
from citar.
Which Emacs version do you use?
I've mostly been using 28, but reverted to 27.2 recently because of an apparent bug that was bothering me.
from citar.
Related Issues (20)
- add an "other window'/"other frame" option for opening notes HOT 1
- prefixes and suffixes in `citar-markdown-insert-citation` HOT 6
- Only citation key being used for narrowing results HOT 6
- Request for Nerd Icons Integration in Citar HOT 4
- Error with inserting citation in LaTeX file: "No such file or directory tex-site" HOT 8
- Feature request: Integration with Zotra HOT 3
- Custom `C-i` bindings do not play well with `citar-open` and `RET` HOT 9
- Feature request: `citar-open-files-or-links` HOT 4
- Customizable `citar-add-file-to-library` HOT 3
- Display transform function for full names HOT 15
- Alignment doesn't work with star in template HOT 1
- Misaligned completion suggestions with company mode HOT 2
- citar--format-candidates docstring confusion
- The Homepage button on melpa leads to a 404 HOT 5
- Installing citar with guix: "Symbol's value as variable is void: citar-indicator-create" HOT 7
- citeproc: add way to specify output format
- Citar fails to display files containing commas HOT 5
- Feature request: Allow `citar` to add multiple files to library item/citeky via `citar-add-file-to-library` HOT 1
- `citar-open-entry` receives wrong citekey HOT 6
- modularizing citar--select-multiple HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from citar.