Comments (32)
Using all-the-icons
works great, by the way:
I'll look into vertico
: should I disable selectrum
for that? (See earlier comment on how I still don't understand how all these different packages interact with one another...)
from citar.
Its value is ((pdf "β" . #1=" ") (note "β" . #1#) (link "π" . #1#))
Is that what the customization field looks like by default, or only after you made changes?
I never use that UI, so possible I did something wrong.
The setq
examples you have demonstrates how the syntax should work, which is the value of that is a two-level alist; conceptually:
(pdf . ("P" . " "))
PS: using all-the-icons works the same way with vertico.... It works fine.
So let's call that a win; the instructions in the README work as expected, on your 27.2, and with selectrum and vertico.
As I said, I don't expect what you're trying to do to work, given my earlier experience with all-the-icons
.
BTW, you can see the history for how we ended up here in #37; in particular this comment: #37 (comment).
But also, I was asking about the default symbols; not all-the-icons
. That's the only remaining question in my view; why that happened to begin with. If it doesn't happen with vertico, it may be an issue with selectrum.
from citar.
BTW, you could use the same approach with the plain symbols; just need the "dim" face.
Good idea. Do you know if there's an easy way to just make the
dim
face always have as foreground the same color as its background? (So it's invisible even when in highlighted.)
No, I don't; why I didn't include it.
But if we could figure that out, could (maybe) standardize on that approach and simplify the config.
Edit: I just looked at the doom and modus themes I use for the README screenshots. Interestingly, they both have a similar "bg-inactive" face, but named slightly differently, and used for different apparent purposes.
from citar.
In case this helps anyone, here's what I ended up doing to avoid depending on all-the-icons
:
(use-package bibtex-actions
:bind ("s-b" . bibtex-actions-open)
:after embark
:custom
(bibtex-actions-template '((t . "${author:15} ${title:40} ${year:4}")))
(bibtex-actions-template-suffix '((t . " ${=key=:15} ${=type=:12} ${tags:*}")))
(bibtex-completion-bibliography '("~/bib/apcmain.bib"))
(bibtex-completion-pdf-field "File")
(bibtex-completion-library-path "~/bib-library/") ; pdfs are assumed to be <key>.pdf
(bibtex-completion-notes-path "~/org/notebook") ; notes are by default <key>.org
:config
(setf (alist-get 'bibtex embark-keymap-alist) 'bibtex-actions-map)
(setq bibtex-actions-symbols
`((pdf . (,(propertize "β" 'face `(:foreground ,(face-attribute 'default :foreground))) .
,(propertize "β" 'face `(:foreground ,(face-attribute 'default :background)))))
(note . (,(propertize "β" 'face `(:foreground ,(face-attribute 'default :foreground))) .
,(propertize "β" 'face `(:foreground ,(face-attribute 'default :background)))))
(link . (,(propertize "‴" 'face `(:foreground ,(face-attribute 'default :foreground))) .
,(propertize "‴" 'face `(:foreground ,(face-attribute 'default :background))))))))
from citar.
This report from a user shows emacs 27.2 (a Mac version) attempting, incorrectly, to apply an affixation function, in the sense that content only defined in that function and only called from affixation-function
is getting rendered in the display.
I thought affixation-function
would simply be ignored for versions that don't support it, but not so.
Have you seen this before @minad?
Adding this as a check solves it for them:
(if (eq action 'metadata 'affixation-function)
(affixation-function . bibtex-actions--affixation))
Is that what I should be doing as a workaround?
Or should I consider this a bug in whatever version of Emacs they are using that I "wontfix"?
from citar.
According to this issue, "Affixation functions work also in Emacs 27, only the default completion system will not use them." Not sure whether this is relevant or helpful or what.
from citar.
No, I have not seen something like this. I suggest you grep for affixation-function
in the emacs source directory to make sure, but from what I know this is a recent addition in 28. And then you can take a look at which completion systems already use it (Selectrum, Vertico, maybe more?). This issue should be narrowed down a bit.
from citar.
OK, thanks @minad.
Actually, my check turns it off for 28 too, so I don't want that.
from citar.
@apc - do you think you can engage with the Mac Emacs project you are using, or the main Emacs project, and see if they might be able to help sort it out on their end?
Or depending on how often they do releases, it might just get resolved in an update?
from citar.
I'll try contacting @railwaycat. Will be in touch if anything comes up. For now, I'll just stick with the fix you suggested earlier.
from citar.
Do you know what is the quickest way to test whatever is going on with affixation-function
in my version of Emacs? Is there some quick test that doesn't require loading bibtex-actions
and co? Thanks!
from citar.
OK, I just installed a different build from here. But I'm running into the same issue:
bibtex-actions-template-suffix is a variable defined in βbibtex-actions.elβ.
Its value is
((t . " ${=has-pdf=:1}${=has-note=:1} ${=key=:15} ${=type=:12} ${tags:*}"))
Original value was
((t . " ${=key=:15} ${=type=:12} ${tags:*}"))
You can customize this variable.
Documentation:
Configures formatting for the BibTeX entry suffix.
When combined wiht the main template, the same string is used for
display and for search.
GNU Emacs 27.2 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version 10.14.6 (Build 18G95)) of 2021-03-27
Not sure what to make of this...
from citar.
Do you know what is the quickest way to test whatever is going on with
affixation-function
in my version of Emacs? Is there some quick test that doesn't require loadingbibtex-actions
and co? Thanks!
Here's a minimal example, that AFAIK should only give you a choice of A, B or C on Emacs 27.
(defun test/affixation (cands)
(mapcar
(lambda (cand)
(list cand "PRE " " SUFF")) cands))
(defun test/read ()
(completing-read
"choose one: "
(lambda (string predicate action)
(if (eq action 'metadata)
`(metadata
(affixation-function . test/affixation))
(complete-with-action action (list "A" "B" "C") string predicate)))))
(test/read)
On Emacs 28, you see the affixes though:
PRE A SUFF
PRE B SUFF
PRE C SUFF
To reproduce the alignment issue, I'm not sure, but given what we've so far, we'd expect you to see some variation of this one.
from citar.
Do you know what is the quickest way to test whatever is going on with
affixation-function
in my version of Emacs? Is there some quick test that doesn't require loadingbibtex-actions
and co? Thanks!Here's a minimal example, that AFAIK should only give you a choice of A, B or C on Emacs 27.
(defun test/affixation (cands) (mapcar (lambda (cand) (list cand "PRE " " SUFF")) cands)) (defun test/read () (completing-read "choose one: " (lambda (string predicate action) (if (eq action 'metadata) `(metadata (affixation-function . test/affixation)) (complete-with-action action (list "A" "B" "C") string predicate))))) (test/read)On Emacs 28, you see the affixes though:
PRE A SUFF PRE B SUFF PRE C SUFF
To reproduce the alignment issue, I'm not sure, but given what we've so far, we'd expect you to see some variation of this one.
FWIF, this is what I get using either the Mac port build or the one from emacsformacosx, which I believe is the same as what you get through brew install --cask emacs
:
from citar.
So affixation indeed works on your Emacs, at least with selectrum.
Did you alter the bibtex-actions-symbols
defcustom at all?
The affixation function uses the cdr value of those entries, by default " ", when pdf or note is not present, which is what preserves alignment when using monospace fonts/symbols.
Which raises the second question: is your font monospace? It sure looks like it, so I doubt this it it.
You might try the all-the-icons
example from the README, which uses a different method to preserve alignment?
If that doesn't work, I'm really not sure what next.
from citar.
I haven't changed the value of bibtex-actions-symbols
, no. I am using the default value of bibtex-completion-pdf-symbol
and of bibtex-completion-notes-symbol
. C-h v bibtex-actions-symbols
gives me this:
bibtex-actions-symbols is a variable defined in βbibtex-actions.elβ.
Its value is ((pdf "β" . #1=" ") (note "β" . #1#) (link "π" . #1#))
You can customize this variable.
Documentation:
Configuration alist specifying which symbol or icon to pick for a bib entry.
This leaves room for configurations where the absense of an item
may be indicated with the same icon but a different face.
[back]
For what is worth, I'm not getting worse misalignment issues with the notes symbol:
I am using a monospace font, yes (Input Mono). I'll try using all-the-icons
as you suggest and report back.
Thanks for your patience!
from citar.
from citar.
from citar.
Here's another interesting fact: if I set the value of bibtex-actions-symbols
from the all-the-icons
example in the README so that at least one of the three values are " "
if there's no corresponding note/file/link, the alignment works just fine:
As soon as I have all three of them set to " "
, though, the problem re-emerges:
Oh, and the same thing happens with vertico
:
from citar.
Just out of curiosity: alignment works alright for you if you use this?
(setq bibtex-actions-symbols
`((pdf . (,(all-the-icons-icon-for-file "foo.pdf" :face 'all-the-icons-dred) .
" "))
(note . (,(all-the-icons-icon-for-file "foo.txt") .
" "))
(link .
(,(all-the-icons-faicon "external-link-square" :v-adjust 0.02 :face 'all-the-icons-dpurple) .
" "))))
from citar.
if I set the value of
bibtex-actions-symbols
from theall-the-icons
example in the README so that at least one of the three values are" "
if there's no corresponding note/file/link, the alignment works just fine... As soon as I have all three of them set to" "
, though, the problem re-emerges:
I think that's because the link glyph is a different width than the others?
IIRC, that's why I used the "dim" face approach, rather than " "
.
You haven't identified similar inconsistency with the default symbols; have you?
And what does vertico
do with the default?
Just out of curiosity: alignment works alright for you if you use this?
I can't easily test that ATM (long story!).
from citar.
I think that's because the link glyph is a different width than the others?
Hmm. But that wouldn't make sense of the alignment being alright if I use " "
for the link instead of the glyph but use the glyph for the pdf:
I'll check with the default symbols and see what vertico
does with them as well. But first, I need help understanding the syntax of the values of bibtex-action-template
.
bibtex-actions-symbols is a variable defined in βbibtex-actions.elβ.
Its value is ((pdf "β" . #1=" ") (note "β" . #1#) (link "π" . #1#))
You can customize this variable.
Documentation:
Configuration alist specifying which symbol or icon to pick for a bib entry.
This leaves room for configurations where the absense of an item
may be indicated with the same icon but a different face.
[back]
Trying to set the value to this:
((pdf "β" . #1#) (note "β" . #1#) (link "π" . #1#))
yields an error: (invalid-read-syntax "#")
.
I also tried something like this, just to see what would happen:
(setq bibtex-actions-symbols '((pdf "β" . #1=" ") (note "β" . "β") (link "π" . #1#)))
but the result is not what I expected (I expected to see the notes glyph on all entries...). Any pointers?
from citar.
PS: using all-the-icons
works the same way with vertico
. If I use this:
(setq bibtex-actions-symbols
`((pdf . (,(all-the-icons-icon-for-file "foo.pdf" :face 'bibtex-actions-icon-on) .
,(all-the-icons-icon-for-file "foo.pdf" :face 'bibtex-actions-icon-dim)))
(note . (,(all-the-icons-icon-for-file "foo.txt" :face 'bibtex-actions-icon-on) .
" "))
(link .
(,(all-the-icons-faicon "external-link-square" :v-adjust 0.02 :face 'all-the-icons-dpurple) .
" "))))
it works fine. If instead I use this:
(setq bibtex-actions-symbols
`((pdf . (,(all-the-icons-icon-for-file "foo.pdf" :face 'bibtex-actions-icon-on) .
" "))
(note . (,(all-the-icons-icon-for-file "foo.txt" :face 'bibtex-actions-icon-on) .
" "))
(link .
(,(all-the-icons-faicon "external-link-square" :v-adjust 0.02 :face 'all-the-icons-dpurple) .
" "))))
the entries appear misaligned.
from citar.
Here's what I see; maybe that's wrong?
from citar.
I don't use the customization interface either. The value I showed you is what I get when doing C-h v
for bibtex-actions-symbols
. I figured you were asking about the default, non-all-the-icons
behavior. I just couldn't figure out how to understand the syntax used here:
bibtex-actions-symbols is a variable defined in βbibtex-actions.elβ.
Its value is ((pdf "β" . #1=" ") (note "β" . #1#) (link "π" . #1#))
You can customize this variable.
Documentation:
Configuration alist specifying which symbol or icon to pick for a bib entry.
This leaves room for configurations where the absense of an item
may be indicated with the same icon but a different face.
[back]
(In particular, I don't know what the #1" "
vs #1#
distinction is supposed to be.)
I'll try fiddling with the customization interface and see if I can get any clarity on what's happening with the default symbols.
from citar.
from citar.
OK, messing with the customization interface allowed me to bypass trying to understand all of that. I now see this if I make one of the 'inactive' values to a non-empty glyph:
In contrast:
The exact same thing happens if I use vertico
instead of selectrum
.
Β―_(γ)_/Β―
from citar.
That's odd. Even the first one, which makes zero sense, isn't perfectly aligned.
I think we can agree this isn't a bibtex-actions bug, and that you should use the all-the-icons
solution?
BTW, you could use the same approach with the plain symbols; just need the "dim" face.
from citar.
That's odd. Even the first one, which makes zero sense, isn't perfectly aligned.
How so? I don't see that...
I think we can agree this isn't a bibtex-actions bug, and that you should use the
all-the-icons
solution?
Yes. Thanks for all your help! You can close this as far as I'm concerned.
BTW, you could use the same approach with the plain symbols; just need the "dim" face.
Good idea. Do you know if there's an easy way to just make the dim
face always have as foreground the same color as its background? (So it's invisible even when in highlighted.)
from citar.
How so? I don't see that...
from citar.
How so? I don't see that...
Whoa
from citar.
OK, one more question, @bdarcus (sorry!). Do you have any idea why the face properties specified as in the all-the-icons
setup from the README are being overridden by selectrum-mouse-highlight
?
Perhaps it'd be best to explain the odd behavior I'm encountering. Using the values for bibtex-actions-symbols
from that snippet in the README, I get (as expected) that the pdf icon (e.g.) for an entry without a corresponding pdf is displayed in the face bibtex-actions-icon-dim
. If, however, my mouse happens to be hovering over that entry, the icon is displayed using (I think?) the default
face:
Without the pesky mouse hovering over anything:
With the mouse:
from citar.
Related Issues (20)
- 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
- citar functions to act on buffers HOT 6
- (How to?) add a direct call to `citar-file-open-external` from citar's "menu"
- Problems rendering superscripts correctly for in-text citations when exporting to ODT HOT 3
- Make citar-open more configurable HOT 9
- Issues with `citar-export-local-bib-file` HOT 8
- embark-related parsing problems when multiple citekeys HOT 14
- Add org-mode markup to citar-insert-reference HOT 1
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.