[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 06/38] org-macs: New function org-find-text-property-region---
From: |
Ihor Radchenko |
Subject: |
[PATCH v2 06/38] org-macs: New function org-find-text-property-region--- |
Date: |
Wed, 20 Apr 2022 21:24:45 +0800 |
---
lisp/org-macs.el | 32 +++++++++++++++++---------------
lisp/org.el | 7 ++++++-
2 files changed, 23 insertions(+), 16 deletions(-)
diff --git a/lisp/org-macs.el b/lisp/org-macs.el
index a09115e7c..6161a7bfc 100644
--- a/lisp/org-macs.el
+++ b/lisp/org-macs.el
@@ -728,7 +728,7 @@ (defsubst org-current-line (&optional pos)
-;;; Overlays
+;;; Overlays and text properties
(defun org-overlay-display (ovl text &optional face evap)
"Make overlay OVL display TEXT with face FACE."
@@ -751,20 +751,22 @@ (defun org-find-overlays (prop &optional pos delete)
(delete (delete-overlay ov))
(t (push ov found))))))
-(defun org-flag-region (from to flag spec)
- "Hide or show lines from FROM to TO, according to FLAG.
-SPEC is the invisibility spec, as a symbol."
- (remove-overlays from to 'invisible spec)
- ;; Use `front-advance' since text right before to the beginning of
- ;; the overlay belongs to the visible line than to the contents.
- (when flag
- (let ((o (make-overlay from to nil 'front-advance)))
- (overlay-put o 'evaporate t)
- (overlay-put o 'invisible spec)
- (overlay-put o
- 'isearch-open-invisible
- (lambda (&rest _) (org-show-context 'isearch))))))
-
+(defun org-find-text-property-region (pos prop)
+ "Find a region around POS containing same non-nil value of PROP text
property.
+Return nil when PROP is not set at POS."
+ (let* ((beg (and (get-text-property pos prop) pos))
+ (end beg))
+ (when beg
+ (unless (or (equal beg (point-min))
+ (not (eq (get-text-property beg prop)
+ (get-text-property (1- beg) prop))))
+ (setq beg (previous-single-property-change pos prop nil (point-min))))
+ (unless (or (equal end (point-max))
+ ;; (not (eq (get-text-property end prop)
+ ;; (get-text-property (1+ end) prop)))
+ )
+ (setq end (next-single-property-change pos prop nil (point-max))))
+ (cons beg end))))
;;; Regexp matching
diff --git a/lisp/org.el b/lisp/org.el
index 855f0813d..b9d2d7834 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -5597,7 +5597,10 @@ (defun org-fontify-like-in-org-mode (s &optional
odd-levels)
(let ((org-odd-levels-only odd-levels))
(org-mode)
(org-font-lock-ensure)
- (buffer-string))))
+ (if org-link-descriptive
+ (org-link-display-format
+ (buffer-string))
+ (buffer-string)))))
(defun org-get-level-face (n)
"Get the right face for match N in font-lock matching of headlines."
@@ -5727,6 +5730,8 @@ (defun org-raise-scripts (limit)
(if (equal (char-after (match-beginning 2)) ?^)
(nth (if table-p 3 1) org-script-display)
(nth (if table-p 2 0) org-script-display)))
+ (put-text-property (match-beginning 2) (match-end 3)
+ 'org-emphasis t)
(add-text-properties (match-beginning 2) (match-end 2)
(list 'invisible t))
(when (and (eq (char-after (match-beginning 3)) ?{)
--
2.35.1
--
Ihor Radchenko,
PhD,
Center for Advancing Materials Performance from the Nanoscale (CAMP-nano)
State Key Laboratory for Mechanical Behavior of Materials, Xi'an Jiaotong
University, Xi'an, China
Email: yantar92@gmail.com, ihor_radchenko@alumni.sutd.edu.sg
- [PATCH v2 00/38] Final call for comments: Merge org-fold feature branch, Ihor Radchenko, 2022/04/20
- [PATCH v2 01/38] Add org-fold-core: new folding engine---, Ihor Radchenko, 2022/04/20
- [PATCH v2 02/38] Separate folding functions from org.el into new library: org-fold, Ihor Radchenko, 2022/04/20
- [PATCH v2 03/38] Separate cycling functions from org.el into new library: org-cycle, Ihor Radchenko, 2022/04/20
- [PATCH v2 04/38] Remove functions from org.el that are now moved elsewhere, Ihor Radchenko, 2022/04/20
- [PATCH v2 05/38] Disable native-comp in agendaIt caused cryptic bugs in the past., Ihor Radchenko, 2022/04/20
- [PATCH v2 06/38] org-macs: New function org-find-text-property-region---,
Ihor Radchenko <=
- [PATCH v2 07/38] org-at-heading-p: Accept optional argument* lisp/org.el (org-at-heading-p): Use second argument to allow, Ihor Radchenko, 2022/04/20
- [PATCH v2 08/38] org-string-width: Reimplement to work with new folding, Ihor Radchenko, 2022/04/20
- [PATCH v2 09/38] Rename old function call to use org-fold---, Ihor Radchenko, 2022/04/20
- [PATCH v2 10/38] Implement link folding* lisp/ol.el (org-link--link-folding-spec):, Ihor Radchenko, 2022/04/20
- [PATCH v2 12/38] org-fold: Handle indirect buffer visibility---, Ihor Radchenko, 2022/04/20
- [PATCH v2 11/38] Implement overlay- and text-property-based versions of some functions, Ihor Radchenko, 2022/04/20
- [PATCH v2 13/38] Fix subtle differences between overlays and invisible text properties, Ihor Radchenko, 2022/04/20
- [PATCH v2 14/38] Support extra org-fold optimisations for huge buffers, Ihor Radchenko, 2022/04/20
- [PATCH v2 15/38] Alias new org-fold functions to their old shorter names, Ihor Radchenko, 2022/04/20
- [PATCH v2 16/38] Obsolete old function names that are now in org-fold---, Ihor Radchenko, 2022/04/20