[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)))))))
- [elpa] branch externals/org-modern created (now 6fadad5cdf), ELPA Syncer, 2022/03/07
- [elpa] externals/org-modern 7c756db91b 06/65: Simplify faces using default specification, ELPA Syncer, 2022/03/07
- [elpa] externals/org-modern 3640955abc 05/65: Use adjusted date and time faces, see #1, ELPA Syncer, 2022/03/07
- [elpa] externals/org-modern a91b994721 11/65: Ensure that time stamps stay editable (Fix #2),
ELPA Syncer <=
- [elpa] externals/org-modern 6b1a560776 04/65: example: Add hrule, ELPA Syncer, 2022/03/07
- [elpa] externals/org-modern 4071382aa0 03/65: Restore line spacing (Fix #1), ELPA Syncer, 2022/03/07
- [elpa] externals/org-modern 2478748a91 02/65: Update README, ELPA Syncer, 2022/03/07
- [elpa] externals/org-modern b66f3ff985 08/65: README: Note that the package is still early in its development., ELPA Syncer, 2022/03/07
- [elpa] externals/org-modern ff1160a03c 07/65: org-modern-label: Fix line-spacing handling, ELPA Syncer, 2022/03/07
- [elpa] externals/org-modern d28951932a 13/65: Ensure that tags stay editable (See #2), ELPA Syncer, 2022/03/07
- [elpa] externals/org-modern be679b3a79 14/65: Improve cursor placement on TODO keywords, ELPA Syncer, 2022/03/07
- [elpa] externals/org-modern a84994dc77 15/65: Improve cursor placement on timestamps (See #2), ELPA Syncer, 2022/03/07
- [elpa] externals/org-modern b17d32c576 16/65: README rewording, ELPA Syncer, 2022/03/07
- [elpa] externals/org-modern 6b925b71ee 19/65: Add org-modern-label-border, do not overwrite line-spacing, ELPA Syncer, 2022/03/07