Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature(ui): add suffix #45

Merged
merged 12 commits into from
Mar 30, 2021
Merged

feature(ui): add suffix #45

merged 12 commits into from
Mar 30, 2021

Conversation

bdarcus
Copy link
Contributor

@bdarcus bdarcus commented Mar 23, 2021

Add suffix UI, using the same configuration method as for the main display formatting.

Also add annotation-function, to provide the same UI pre-Emacs 28..

To enable this, I have adapted some code from bibtex-completion. I will
that code, or greatly simplify it, if and when this PR is merged:

tmalsburg/helm-bibtex#367

Closes #44


Here's what it looks like now, with these two PRs, and configured to use all-the-icons:

Screenshot from 2021-03-26 11-04-25

@mtreca

This comment has been minimized.

@bdarcus

This comment has been minimized.

@bdarcus bdarcus force-pushed the suffix branch 2 times, most recently from f667d95 to fd1267b Compare March 25, 2021 19:40
bibtex-actions.el Outdated Show resolved Hide resolved
@mtreca

This comment has been minimized.

@bdarcus
Copy link
Contributor Author

bdarcus commented Mar 26, 2021

One of the nice side effects of using affixes is the target display string can be much more compact, which makes the current selectrum multi-select UI work better.

(add (s-trim-right (s-join " " (list pdf note link))))
; TODO: add separation between target and suffix
(suffix (bibtex-completion-format-entry candidate (1- (frame-width))
bibtex-completion-display-formats-suffix)))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and the template setq are the only pieces of code dependent on the bibtex-completion PR. Could comment out and add a fixed placeholder for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and the template setq are the only pieces of code dependent on the bibtex-completion PR. Could comment out and add a fixed placeholder for now.

Latest commit implements this. I'll wait a bit to see if Titus responds.

Copy link
Contributor Author

@bdarcus bdarcus Mar 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other alternative is to just add the two functions we need to do this ourselves, and then do this, so all of it is configurable. Can then remove or simplify if and when the other PR is accepted.

(defcustom bibtex-actions-display-templates
  ; prefix will only work with rich ui, and on Emacs 28
  ; 'target' is the default entry display string
  '((prefix . '((t. "${=has-pdf=:1} ${=has-note=:1}  ")))
    ; could just use bibtex-completion-display-formats here
    (target . '((t . "${author:20}   ${title:48}   ${year:4}")))
    (suffix . '((t. "          ${=key=:15}    ${=type=:12}    ${tags:*}"))))
    "Configures display formatting for 'target', 'prefix' and 'suffix'.
The latter two are optional, but are used in the 'rich ui'."
    :group 'bibtex-actions
    :type  '(alist :key-type symbol :value-type function))

@bdarcus bdarcus mentioned this pull request Mar 27, 2021
bdarcus added 3 commits March 27, 2021 19:25
Adapt the formatting logic from bibtex-completion to bibtex-actions, and
make prefix, target and suffix all configurable, using the same code and
config.

Also, change 'bibtex-actions-icons' to 'bibtex-actions-symbols'.
@bdarcus
Copy link
Contributor Author

bdarcus commented Mar 30, 2021

OK, I changed the branch to not rely on the bibtex-completion PR. I'll take another look in the morning, and may merge it at that point.

One thing: in bibtex-completion, the templates variables are updated in the init function.

Here, I do it in a variable on the -format-entry function.

Am not sure what relative pros and cons of each approach is. Certainly for this, it's easier as it's self-contained.

@bdarcus bdarcus merged commit ca2c7b8 into main Mar 30, 2021
@bdarcus bdarcus deleted the suffix branch March 30, 2021 07:49
bdarcus added a commit that referenced this pull request Mar 30, 2021
Add suffix UI, using the same configuration method as for the main display formatting.

Also add annotation-function, to provide the same UI pre-Emacs 28..

To enable this, I have adapted some code from bibtex-completion. I will
remove that code, or greatly simplify it, if and when this PR is merged:

tmalsburg/helm-bibtex#367

Also, change 'bibtex-actions-icons' to 'bibtex-actions-symbols'.

Closes #44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add suffix UI
2 participants