Skip to content

Commit

Permalink
fixed two issues related issue #1120
Browse files Browse the repository at this point in the history
1. tooltip error when point is in another buffer
2. tooltips are not nil when using an acronym with  glossary link
  • Loading branch information
Your Name committed Aug 2, 2024
1 parent db133f8 commit fd178ab
Showing 1 changed file with 28 additions and 26 deletions.
54 changes: 28 additions & 26 deletions org-ref-glossary.el
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ changes."
set data on text with properties
Set face property, and help-echo."
(let ((data (or (or-parse-glossary-entry path)
(or-parse-acronym-entry path))))
(or-parse-acronym-entry path))))
(add-text-properties
start end
(list 'or-glossary data
Expand All @@ -295,22 +295,23 @@ Set face property, and help-echo."
(goto-char (plist-get (get-text-property (point) 'or-glossary) :position)))


(defun or-glossary-tooltip (_window _object position)
(defun or-glossary-tooltip (_window buffer position)
"Return tooltip for the glossary entry.
The entry is in WINDOW and OBJECT at POSITION.
Used in fontification."
(let* ((data (get-text-property position 'or-glossary))
(name (or (plist-get data :name)
(plist-get data :abbrv)))
(description (or (plist-get data :description)
(plist-get data :full))))
(format
"%s: %s"
name
(with-temp-buffer
(insert (concat description "."))
(fill-paragraph)
(buffer-string)))))
Used in fontification."
(with-current-buffer buffer
(let* ((data (get-text-property position 'or-glossary))
(name (or (plist-get data :name)
(plist-get data :abbrv)))
(description (or (plist-get data :description)
(plist-get data :full))))
(format
"%s: %s"
name
(with-temp-buffer
(insert (concat description "."))
(fill-paragraph)
(buffer-string))))))


(defvar org-ref-glossary-gls-commands
Expand Down Expand Up @@ -533,21 +534,22 @@ Set face property, and help-echo."
"Face for acronym links.")


(defun or-acronym-tooltip (_window _object position)
(defun or-acronym-tooltip (_window buffer position)
"Return tooltip for the acronym entry.
The entry is in WINDOW and OBJECT at POSITION.
Used in fontification.
WINDOW and OBJECT are ignored."
(save-excursion
(goto-char position)
(let* ((acronym-data (get-text-property position 'or-glossary))
(abbrv (plist-get acronym-data :abbrv))
(full (plist-get acronym-data :full)))
(if acronym-data
(format
"%s: %s"
abbrv full)
(format "This is not defined in this file.")))))
(with-current-buffer buffer
(save-excursion
(goto-char position)
(let* ((acronym-data (get-text-property position 'or-glossary))
(abbrv (plist-get acronym-data :abbrv))
(full (plist-get acronym-data :full)))
(if acronym-data
(format
"%s: %s"
abbrv full)
(format "This is not defined in this file."))))))


(defvar org-ref-acronym-types
Expand Down

0 comments on commit fd178ab

Please sign in to comment.