[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org-remark 175ba6d06e 44/75: fix(line):when line-icon i
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org-remark 175ba6d06e 44/75: fix(line):when line-icon is an image, it fails to carry face |
Date: |
Fri, 6 Oct 2023 12:59:19 -0400 (EDT) |
branch: externals/org-remark
commit 175ba6d06ec2dde56148c366eb609d81be53fdea
Author: Noboru Ota <me@nobiot.com>
Commit: Noboru Ota <me@nobiot.com>
fix(line):when line-icon is an image, it fails to carry face
The notes icon from `org-remark-icon` package was made available to
`org-remrk-line`; however, it was assumed that the highlight the icon is
added to is an overlay added to the main text. This assumption does not
hold for line-highlights available with `org-remark-line`. It is likely
that the user customize the glyph to be displayed in the margin to be
an SVG icon. In this case, the notes icon (the icon that is added to the
highlight when the user has written an annotation to it) is added onto
another overlay to another SVG icon. This fix caters to this case, and
let the notes icon carry the same face as the underlying line-highlight
overlay.
LIMITATION made clear: if the user wants to use image icons (e.g. SVG
image icon created with package `icons', available Emacs 29.1 or
higher), it is limited to a single character with no space before and
after the character. This limitation does not apply to string of
characters without images, but it is generally assumed that the the
value set to this customizing variable will be a short string (e.g 3
characters long with a pair of parentheses before and after a single
character, such as the default value of icon customizing variables.
---
org-remark-icon.el | 22 ++++++++++++--
org-remark-line.el | 84 +++++++++++++++++++++++++++++++++++-------------------
2 files changed, 74 insertions(+), 32 deletions(-)
diff --git a/org-remark-icon.el b/org-remark-icon.el
index 557e08f4f2..3cca7c1c31 100644
--- a/org-remark-icon.el
+++ b/org-remark-icon.el
@@ -46,7 +46,16 @@ and/or text-property to the string. This means you can
return a
string with a display property to show an SVG icon instead of the
underlying string.
-Nil means no icon is to be displayed."
+Nil means no icon is to be displayed.
+
+If you wants to use image icons (e.g. SVG image icon created with
+package `icons', available Emacs 29.1 or higher), you're limited
+to a single character with no space before and after the
+character. This limitation does not apply to string of characters
+without images, but it is generally assumed that the the value
+set to this customizing variable will be a short string (e.g 3
+characters long with a pair of parentheses before and after a
+single character, such as the default value.)"
:safe #'stringp
:type '(choice
(string "(*)")
@@ -63,7 +72,16 @@ and/or text-property to the string. This means you can
return a
string with a display property to show an SVG icon instead of the
underlying string.
-Nil means no icon is to be displayed."
+Nil means no icon is to be displayed.
+
+If you wants to use image icons (e.g. SVG image icon created with
+package `icons', available Emacs 29.1 or higher), you're limited
+to a single character with no space before and after the
+character. This limitation does not apply to string of characters
+without images, but it is generally assumed that the the value
+set to this customizing variable will be a short string (e.g 3
+characters long with a pair of parentheses before and after a
+single character, such as the default value."
:safe #'stringp
:type '(choice
(string "(d)")
diff --git a/org-remark-line.el b/org-remark-line.el
index 59a32e3c61..8eec55ebee 100644
--- a/org-remark-line.el
+++ b/org-remark-line.el
@@ -30,6 +30,25 @@
(require 'org-remark)
+(defcustom org-remark-line-icon " * "
+ "Glyph displayed on the margin to indicate the line-highlight.
+If you wants to use image icons (e.g. SVG image icon created with
+package `icons', available Emacs 29.1 or higher), you're limited
+to a single character with no space before and after the
+character. This limitation does not apply to string of characters
+without images, but it is generally assumed that the the value
+set to this customizing variable will be a short string (e.g 3
+characters long with a padding spaces before and after a single
+character, such as the default value.)"
+ :local t
+ :type 'string
+ :safe 'stringp)
+
+(defvar org-remark-line-minimum-margin-width 3)
+
+(defvar org-remark-line-margin-padding 1
+ "Padding between the main text area the icon on the margin")
+
(defcustom org-remark-line-margin-side 'left-margin
"The side of margin to display line highlights.
Left or rigth can be chosen."
@@ -38,6 +57,10 @@ Left or rigth can be chosen."
(const :tag "Left margin" left-margin)
(const :tag "Right margin" right-margin)))
+(defvar org-remark-line-heading-title-max-length 40)
+
+(defvar org-remark-line-ellipsis "…")
+
(defface org-remark-line-highlighter
'((((class color) (min-colors 88) (background light))
:foreground "#dbba3f")
@@ -47,8 +70,6 @@ Left or rigth can be chosen."
:inherit highlight))
"Face for the default line highlighter pen.")
-(defvar org-remark-line-icon " * ")
-
(defvar org-remark-line-heading-title-max-length 40)
(defvar org-remark-line-ellipsis "…")
@@ -171,10 +192,7 @@ by `overlays-in'."
"Return a spacer overlay."
(let* ((left-margin (or (car (window-margins)) left-margin-width))
(right-margin (or (cdr (window-margins)) right-margin-width))
- (string (with-temp-buffer
- (insert org-remark-line-icon)
- (buffer-string)))
- (string-length (length string))
+ (string-length (length org-remark-line-icon))
(spaces-base-length (if (eql org-remark-line-margin-side
'right-margin)
org-remark-line-margin-padding
(- left-margin
@@ -216,22 +234,32 @@ by `overlays-in'."
(org-remark-highlights-housekeep)
(org-remark-highlights-sort))))))))
+(defun org-remark-line-highlight-propertize (ov icon-string)
+ ;; If the icon-string has a display properties, assume it is an icon image
+ (let ((display-prop (get-text-property 0 'display icon-string)))
+ (cond (display-prop ; svg-based icon
+ (let* ((display-prop (list `(margin ,org-remark-line-margin-side)
display-prop))
+ (icon-face (get-text-property 0 'face icon-string))
+ (icon-string (propertize " " 'display display-prop)))
+ (when icon-face
+ (setq icon-string (propertize icon-string 'face icon-face)))
+ (overlay-put ov 'before-string icon-string)))
+ (icon-string ; text/string-based icon
+ (let ((icon-string icon-string))
+ (overlay-put ov 'before-string (propertize " " 'display (list
`(margin ,org-remark-line-margin-side) icon-string)))))
+ (t (ignore)))))
+
(cl-defmethod org-remark-highlight-make-overlay (beg end face
(_org-remark-type (eql 'line)))
"Make and return a highlight overlay for line-highlight.
Return nil when no window is created for current buffer."
(when (get-buffer-window)
(unless org-remark-line-mode (org-remark-line-mode +1))
(let* ((face (or face 'org-remark-line-highlighter))
- (string (with-temp-buffer
- (insert org-remark-line-icon)
- (buffer-string)))
+ (string (propertize org-remark-line-icon 'face face))
(spacer-ov (org-remark-line-make-spacer-overlay beg))
(ov (make-overlay beg end nil :front-advance)))
;; line-highlight overlay
- (overlay-put ov 'before-string
- (propertize " " 'display
- `((margin ,org-remark-line-margin-side)
- ,(propertize string 'face face))))
+ (org-remark-line-highlight-propertize ov string)
;; Let highlight overlay to take care of the spacer movement
(overlay-put ov 'insert-in-front-hooks (list
'org-remark-line-highlight-modified))
;; Copy spacer overlay. It is put after the line-highlight to
@@ -303,28 +331,24 @@ end of overlay being identical."
(move-overlay ov ov-line-bol ov-line-bol)))))
(cl-defmethod org-remark-icon-overlay-put (ov icon-string (_org-remark-type
(eql 'line)))
- "
+ "Add icons to OV.
+ Each overlay is a highlight.
Return nil when no window is created for current buffer."
(when (get-buffer-window)
- ;; If the icon-string has a display properties, assume it is an icon image
- (let ((display-prop (get-text-property 0 'display icon-string)))
- (cond (display-prop ; svg-based icon
- (let* ((display-prop (list `(margin ,org-remark-line-margin-side)
display-prop))
- (icon-face (get-text-property 0 'face icon-string))
- (icon-string (propertize " " 'display display-prop)))
- (when icon-face
- (setq icon-string (propertize icon-string 'face icon-face)))
- (overlay-put ov 'before-string icon-string)))
- (icon-string ; text/string-based icon
- (let ((icon-string icon-string))
- (overlay-put ov 'before-string (propertize " " 'display (list
`(margin ,org-remark-line-margin-side) icon-string)))))
- (t (ignore))))))
+ (org-remark-line-highlight-propertize ov icon-string)))
(cl-defmethod org-remark-icon-highlight-get-face (highlight (_org-remark-type
(eql 'line)))
"Return the face of the line-highilght in a margin."
- (get-text-property 0 'face
- (cadr (get-text-property 0 'display
- (overlay-get highlight
'before-string)))))
+ (let* ((before-string (overlay-get highlight 'before-string))
+ (face (get-text-property 0 'face before-string)))
+ ;; When the highlight already is an SVG icon, face is in the display
+ ;; property of before-string
+ (unless face
+ (let ((display-string
+ (cadr (get-text-property 0 'display before-string))))
+ (when (stringp display-string)
+ (setq face (get-text-property 0 'face display-string)))))
+ face))
(provide 'org-remark-line)
;;; org-remark-line.el ends here
- [elpa] externals/org-remark 2bba54b535 05/75: fix: selecting wrong highlight when opening, (continued)
- [elpa] externals/org-remark 2bba54b535 05/75: fix: selecting wrong highlight when opening, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 51c3d91585 11/75: refactor: create macro & menus, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark ae376d860d 09/75: refactor(line): method name change, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 89ee82935c 14/75: fix: window margins do not persist, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 16958accc2 02/75: refactor: org-remark-mark, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark da73102a2d 19/75: fix(line): When source is narrowed line-hl moves the wrong place, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 79ad1baf7e 20/75: refactor(line): no need for text-scale-mode-hook, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 0829e27379 39/75: fix(line): redraw instead of reload when window size changes, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 4156342f88 40/75: refactor(line): make spacer overlay, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 9f86daaee6 43/75: feat(line):Redraw can now change the margin side, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 175ba6d06e 44/75: fix(line):when line-icon is an image, it fails to carry face,
ELPA Syncer <=
- [elpa] externals/org-remark a879b66013 59/75: docs: docstring for new auto-delete feature, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 03828f44e4 65/75: docs: README to include use-package setup example, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 3ea41202e6 58/75: feat: #21 Delete notes when highlight removed if the notes are empty, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 1df1fcb331 46/75: feat(line): define various customizing options, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 063f68e5a4 36/75: feat(line): right margin, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark cdcab9e294 73/75: docs: v1.3, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark c1c120f0c9 45/75: feat(line):defcustom org-remark-line-minimum-margin-width, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark c506e61017 55/75: fix(line): `org-remark-mark-line` does not autoload, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 822e730fc8 75/75: Merge branch 'dev/1.3.0', ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark d5a3fcf612 17/75: refactor(create): quoting org-remark-type value, ELPA Syncer, 2023/10/06