Giter Site home page Giter Site logo

Comments (32)

apc avatar apc commented on August 19, 2024 1

Using all-the-icons works great, by the way:

image

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.

bdarcus avatar bdarcus commented on August 19, 2024 1

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.

bdarcus avatar bdarcus commented on August 19, 2024 1

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.

apc avatar apc commented on August 19, 2024 1

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.

bdarcus avatar bdarcus commented on August 19, 2024

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.

apc avatar apc commented on August 19, 2024

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.

minad avatar minad commented on August 19, 2024

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.

bdarcus avatar bdarcus commented on August 19, 2024

OK, thanks @minad.

Actually, my check turns it off for 28 too, so I don't want that.

from citar.

bdarcus avatar bdarcus commented on August 19, 2024

@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.

apc avatar apc commented on August 19, 2024

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.

apc avatar apc commented on August 19, 2024

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.

apc avatar apc commented on August 19, 2024

OK, I just installed a different build from here. But I'm running into the same issue:

image

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.

bdarcus avatar bdarcus commented on August 19, 2024

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!

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.

apc avatar apc commented on August 19, 2024

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!

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:

image

from citar.

bdarcus avatar bdarcus commented on August 19, 2024

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.

apc avatar apc commented on August 19, 2024

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:

image

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.

bdarcus avatar bdarcus commented on August 19, 2024

from citar.

bdarcus avatar bdarcus commented on August 19, 2024

from citar.

apc avatar apc commented on August 19, 2024

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:

image

As soon as I have all three of them set to " ", though, the problem re-emerges:

image

Oh, and the same thing happens with vertico:

image

from citar.

apc avatar apc commented on August 19, 2024

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.

bdarcus avatar bdarcus commented on August 19, 2024

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:

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.

apc avatar apc commented on August 19, 2024

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:

image

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.

apc avatar apc commented on August 19, 2024

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.

bdarcus avatar bdarcus commented on August 19, 2024

Here's what I see; maybe that's wrong?

Screenshot from 2021-04-17 10-57-00

from citar.

apc avatar apc commented on August 19, 2024

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.

bdarcus avatar bdarcus commented on August 19, 2024

from citar.

apc avatar apc commented on August 19, 2024

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:

image

In contrast:

image

The exact same thing happens if I use vertico instead of selectrum.

Β―_(ツ)_/Β―

from citar.

bdarcus avatar bdarcus commented on August 19, 2024

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.

apc avatar apc commented on August 19, 2024

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.

bdarcus avatar bdarcus commented on August 19, 2024

How so? I don't see that...

Screenshot from 2021-04-17 15-07-55

from citar.

apc avatar apc commented on August 19, 2024

How so? I don't see that...

Screenshot from 2021-04-17 15-07-55

Whoa

from citar.

apc avatar apc commented on August 19, 2024

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:

image

With the mouse:

image

from citar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.