emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/org-modern a91b994721 11/65: Ensure that time stamps st


From: ELPA Syncer
Subject: [elpa] externals/org-modern a91b994721 11/65: Ensure that time stamps stay editable (Fix #2)
Date: Mon, 7 Mar 2022 12:57:45 -0500 (EST)

branch: externals/org-modern
commit a91b994721f722905a64296b0cf9f88315db477e
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Ensure that time stamps stay editable (Fix #2)
---
 README.org    | 13 ++++++------
 org-modern.el | 66 +++++++++++++++++++++++++++++++++++++++++------------------
 2 files changed, 53 insertions(+), 26 deletions(-)

diff --git a/README.org b/README.org
index d86b523baa..a21de79614 100644
--- a/README.org
+++ b/README.org
@@ -5,7 +5,7 @@
 #+html: <a href="https://www.gnu.org/software/emacs/";><img alt="GNU Emacs" 
src="https://github.com/minad/corfu/blob/screenshots/emacs.svg?raw=true"/></a>
 
 This package implements a "modern" style for your Org buffers using font 
locking
-and display properties. The package styles headlines, keywords, tables and
+and text properties. The package styles headlines, keywords, tables and
 source blocks. The styling is configurable, you can enable, disable or modify
 the style of each syntax element individually. Take a look at the =org-modern=
 customization group.
@@ -17,10 +17,11 @@ Org elements deserve styling or alternative stylings should 
be offered?
 
 The tag style of =org-modern= is a poor Emacsien's ripoff from Nicholas 
Rougier's
 beautiful [[https://github.com/rougier/svg-tag-mode][svg-tag-mode]]. In 
contrast to =svg-tag-mode=, this package avoids images
-and uses cheap and fast Emacs box display properties. Unfortunately this
-significantly restricts the flexibility in styling and may lead to
-font-dependent issues. We do our best, but for example there is no way we can
-round corners. Of course a combination of =org-modern= with =svg-tag-mode= is
+and uses cheap and fast Emacs box text properties. Unfortunately this restricts
+the flexibility in styling and may lead to font-dependent issues. We do our
+best, but for example there is no way we can round corners. On the upside by
+only styling the text via text properties, the text stays editable and easy to
+interact with. Of course a combination of =org-modern= with =svg-tag-mode= is
 possible. You can use SVG tags and use the table and block styling from
 =org-modern=. If you are interested in further tweaks, Emacs comes with the
 builtin =prettify-symbols-mode= which can be used for individual styling of 
custom
@@ -28,7 +29,7 @@ keywords.
 
 Another very popular alternative is 
[[https://github.com/integral-dw/org-superstar-mode][org-superstar]], which has 
a more restricted
 feature set and mainly adjusts headlines and lists. =org-superstar= relies on
-character composition, while =org-modern= uses display properties, which are
+character composition, while =org-modern= uses text properties, which are
 considered more future-proof.
 
 This is a screenshot of [[file:example.org][example.org]] with =org-modern= 
turned on and off. The theme
diff --git a/org-modern.el b/org-modern.el
index 3838df907b..b9750223e4 100644
--- a/org-modern.el
+++ b/org-modern.el
@@ -281,26 +281,52 @@ Set to nil to disable the progress bar."
 
 (defun org-modern--timestamp ()
   "Prettify timestamps."
-  (let ((beg (match-beginning 0))
-        (end (match-end 0))
-        (active (eq (char-after (match-beginning 0)) ?<))
-        (date (match-string 1))
-        (time (match-string 2)))
+  (let* ((active (eq (char-after (match-beginning 0)) ?<))
+         (date-face (if active
+                        'org-modern-date-active
+                      'org-modern-date-inactive))
+         (time-face (if active
+                        'org-modern-time-active
+                      'org-modern-time-inactive)))
     (put-text-property
-     beg end
-     'display
-     (concat
-      (propertize (concat " " date " ")
-                  'face
-                  (if active
-                      'org-modern-date-active
-                    'org-modern-date-inactive))
-      (and time
-           (propertize (concat " " time " ")
-                       'face
-                       (if active
-                           'org-modern-time-active
-                         'org-modern-time-inactive)))))))
+     (match-beginning 0)
+     (1+ (match-beginning 0))
+     'display " ")
+    (put-text-property
+     (1- (match-end 0))
+     (match-end 0)
+     'display " ")
+    ;; year
+    (put-text-property
+     (match-beginning 0)
+     (match-end 1)
+     'face date-face)
+    ;; month
+    (put-text-property
+     (match-beginning 2)
+     (match-end 2)
+     'face date-face)
+    ;; day
+    (put-text-property
+     (match-beginning 3)
+     (if (match-end 4) (match-end 3) (match-end 0))
+     'face date-face)
+    (when (match-end 4)
+      (put-text-property
+       (match-beginning 4)
+       (1+ (match-beginning 4))
+       'display (format " %c"
+                        (char-after (match-beginning 4))))
+      ;; hour
+      (put-text-property
+       (match-beginning 4)
+       (match-end 4)
+       'face time-face)
+      ;; minute
+      (put-text-property
+       (match-beginning 5)
+       (match-end 0)
+       'face time-face))))
 
 (defun org-modern--star ()
   "Prettify headline stars."
@@ -421,7 +447,7 @@ Set to nil to disable the progress bar."
       (when org-modern-tag
         '(("^\\*+.*?\\( \\)\\(:.*:\\)[ \t]*$" (0 (org-modern--tag)))))
       (when org-modern-timestamp
-        '(("\\(?:<\\|\\[\\)\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}\\(?: 
[A-Za-z]+\\)?\\)\\(?: \\([0-9]\\{2\\}:[0-9]\\{2\\}\\)\\)?\\(?:>\\|\\]\\)"
+        
'(("\\(?:<\\|\\[\\)\\([0-9]\\{4\\}-\\)\\([0-9]\\{2\\}-\\)\\([0-9]\\{2\\}\\(?: 
[A-Za-z]+\\)? ?\\)\\(?:\\([0-9]\\{2\\}:\\)\\([0-9]\\{2\\}\\)\\)?\\(?:>\\|\\]\\)"
            (0 (org-modern--timestamp)))))
       (when org-modern-statistics
         '((" \\[\\(\\([0-9]+\\)%\\|\\([0-9]+\\)/\\([0-9]+\\)\\)\\]" (0 
(org-modern--statistics)))))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]