[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org-real 47d52107b2 111/188: Refactoring; killing org r
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org-real 47d52107b2 111/188: Refactoring; killing org real buffer if it exists before recreating |
Date: |
Sun, 5 May 2024 22:56:00 -0400 (EDT) |
branch: externals/org-real
commit 47d52107b215436f37e20528eddf486a2987e7d6
Author: Amy Grinn <grinn.amy@gmail.com>
Commit: Amy Grinn <grinn.amy@gmail.com>
Refactoring; killing org real buffer if it exists before recreating
---
org-real.el | 112 +++++++++++++++++++++++++++++++++---------------------------
1 file changed, 61 insertions(+), 51 deletions(-)
diff --git a/org-real.el b/org-real.el
index 8018be08b0..0be47d6ef7 100644
--- a/org-real.el
+++ b/org-real.el
@@ -396,22 +396,14 @@ MAX-LEVEL is the maximum level to show headlines for."
(org-real--flex-adjust org-real--current-box)
(let ((inhibit-read-only t))
(erase-buffer)
- (setq org-real--box-ring '())
(if org-real--current-containers
(org-real--pp-text org-real--current-containers))
(setq org-real--current-offset (- (line-number-at-pos)
org-real-margin-y
(* 2 org-real-padding-y)))
- (let ((box-coords (org-real--draw org-real--current-box)))
- (setq org-real--box-ring
- (seq-sort
- '<
- (mapcar
- (lambda (coords)
- (forward-line (- (car coords) (line-number-at-pos)))
- (move-to-column (cdr coords))
- (point))
- box-coords))))
+ (org-real--draw org-real--current-box)
+ (setq org-real--box-ring
+ (seq-sort '< (org-real--get-positions org-real--current-box)))
(goto-char (point-max))
(insert "\n")
(goto-char 0)))
@@ -474,6 +466,8 @@ it.
VISIBILITY is the initial visibility of children and
MAX-VISIBILITY is the maximum depth to display when cycling
visibility."
+ (if-let ((buffer (get-buffer "Org Real")))
+ (kill-buffer buffer))
(let ((buffer (get-buffer-create "Org Real")))
(with-current-buffer buffer
(org-real-mode)
@@ -485,7 +479,6 @@ visibility."
(org-real-mode-redraw)
(let* ((width (apply 'max (mapcar 'length (split-string (buffer-string)
"\n"))))
(height (count-lines (point-min) (point-max)))
- (buffer (get-buffer-create "Org Real"))
(window (or (get-buffer-window buffer)
(display-buffer buffer
`(,(or display-buffer-fn
@@ -637,7 +630,7 @@ ORIG is `org-insert-link', ARGS are the arguments passed to
it."
(ignore-errors
(url-type
(url-generic-parse-url link))))
- (plist-get (car (last
(org-real--parse-url link nil)))
+ (plist-get (car (last
(org-real--parse-url link)))
:name))))))
(unwind-protect
(if (called-interactively-p 'any)
@@ -764,6 +757,26 @@ non-nil, skip setting :primary slot on the last box."
(org-real--merge-into (pop boxes) world))
world)))
+(cl-defmethod org-real--merge-into ((from org-real-box) (to org-real-box))
+ "Merge FROM box into TO box."
+ (let (match-found)
+ (mapc
+ (lambda (from-box)
+ (let ((match (org-real--find-matching from-box to)))
+ (while (and (not match) (slot-boundp from-box :rel-box))
+ (setq from-box (with-slots (rel-box) from-box rel-box))
+ (setq match (org-real--find-matching from-box to)))
+ (when match
+ (setq match-found t)
+ (org-real--add-matching from-box match))))
+ (org-real--primary-boxes from))
+ (unless match-found
+ (let ((all-from-children (org-real--get-children from 'all)))
+ (with-slots ((to-children children) (to-behind behind)) to
+ (if (= 1 (length all-from-children))
+ (org-real--flex-add (car all-from-children) to)
+ (org-real--flex-add from to)))))))
+
(cl-defmethod org-real--update-visibility ((box org-real-box))
"Update visibility of BOX and all of its children."
(with-slots (level children hidden-children expand-children) box
@@ -787,6 +800,19 @@ non-nil, skip setting :primary slot on the last box."
(org-real--get-all children))))))
(mapc 'org-real--update-visibility (org-real--get-children box 'all)))
+(cl-defmethod org-real--get-positions ((box org-real-box))
+ "Get the buffer position of the names of BOX and its children."
+ (if-let ((pos (and (slot-boundp box :name)
+ (let ((top (org-real--get-top box))
+ (left (org-real--get-left box)))
+ (forward-line (- (+ org-real--current-offset 1 top
org-real-padding-y)
+ (line-number-at-pos)))
+ (move-to-column (+ 1 left org-real-padding-x))
+ (point)))))
+ (apply 'append (list pos) (mapcar 'org-real--get-positions
(org-real--get-children box)))
+ (apply 'append (mapcar 'org-real--get-positions (org-real--get-children
box)))))
+
+
;;;; Drawing
(cl-defmethod org-real--draw ((box org-real-box) &optional arg)
@@ -1096,27 +1122,23 @@ If INCLUDE-ON-TOP is non-nil, also include height on
top of box."
(cl-defmethod org-real--create-cursor-function ((box org-real-box))
"Create cursor functions for entering and leaving BOX."
(with-slots (rel rel-box name metadata) box
- (let (timer)
+ (let (tooltip-timer)
(lambda (_window _oldpos dir)
(let ((inhibit-read-only t))
(save-excursion
(if (eq dir 'entered)
(progn
- (if org-real-tooltips
- (setq timer
- (run-with-idle-timer
- org-real-tooltip-timeout nil
- (lambda ()
- (if (slot-boundp box :metadata)
- (org-real--tooltip metadata)
- (if (and (slot-boundp box :name) (slot-boundp
box :rel))
- (with-slots ((rel-name name)) rel-box
- (org-real--tooltip (format "The %s is
%s the %s."
- name rel
rel-name)))))))))
+ (if (slot-boundp box :metadata)
+ (setq tooltip-timer (org-real--tooltip metadata))
+ (if (and (slot-boundp box :name) (slot-boundp box :rel))
+ (with-slots ((rel-name name)) rel-box
+ (setq tooltip-timer
+ (org-real--tooltip (format "The %s is %s the
%s."
+ name rel
rel-name))))))
(if (slot-boundp box :rel-box)
(org-real--draw rel-box 'rel))
(org-real--draw box 'selected))
- (if timer (cancel-timer timer))
+ (if tooltip-timer (cancel-timer tooltip-timer))
(if (slot-boundp box :rel-box)
(org-real--draw rel-box t))
(org-real--draw box t))))))))
@@ -1169,7 +1191,7 @@ If INCLUDE-ON-TOP is non-nil, also include height on top
of box."
"Jump to the box directly related to BOX."
(with-slots (rel-box) box
(if (not (slot-boundp box :rel-box))
- 'identity
+ (lambda () (interactive))
(let ((left (org-real--get-left rel-box))
(top (org-real--get-top rel-box)))
(lambda ()
@@ -1409,26 +1431,6 @@ PREV must already exist in PARENT."
(lambda (next) (org-real--add-next next match))
(org-real--next box)))
-(cl-defmethod org-real--merge-into ((from org-real-box) (to org-real-box))
- "Merge FROM box into TO box."
- (let (match-found)
- (mapc
- (lambda (from-box)
- (let ((match (org-real--find-matching from-box to)))
- (while (and (not match) (slot-boundp from-box :rel-box))
- (setq from-box (with-slots (rel-box) from-box rel-box))
- (setq match (org-real--find-matching from-box to)))
- (when match
- (setq match-found t)
- (org-real--add-matching from-box match))))
- (org-real--primary-boxes from))
- (unless match-found
- (let ((all-from-children (org-real--get-children from 'all)))
- (with-slots ((to-children children) (to-behind behind)) to
- (if (= 1 (length all-from-children))
- (org-real--flex-add (car all-from-children) to)
- (org-real--flex-add from to)))))))
-
(cl-defmethod org-real--add-next ((next org-real-box)
(prev org-real-box)
&optional force-visible)
@@ -1753,9 +1755,17 @@ characters if possible."
(defun org-real--tooltip (str)
"Show a popup tooltip with STR contents."
- (popup-tip (concat "\n" str "\n")
- :parent-offset 1
- :margin org-real-padding-x))
+ (let ((marker (point-marker)))
+ (when org-real-tooltips
+ (run-with-idle-timer
+ org-real-tooltip-timeout nil
+ (lambda ()
+ (if (and (eq (marker-buffer marker)
+ (current-buffer))
+ (eq (marker-position marker)
+ (point)))
+ (popup-tip (concat "\n" str "\n")
+ :margin org-real-padding-x)))))))
(defun org-real--find-last-index (pred sequence)
"Return the index of the last element for which (PRED element) is non-nil in
SEQUENCE."
@@ -1789,7 +1799,7 @@ LINK is escaped with backslashes for inclusion in buffer."
(org-link-escape link)
(if description (format "[%s]" description) "")))))
-(defun org-real--parse-url (str marker)
+(defun org-real--parse-url (str &optional marker)
"Parse STR into a list of plists.
Returns a list of plists with a :name property and optionally a
- [elpa] externals/org-real 8321f7feff 088/188: # `org-real-headlines`, (continued)
- [elpa] externals/org-real 8321f7feff 088/188: # `org-real-headlines`, ELPA Syncer, 2024/05/05
- [elpa] externals/org-real f260ca8e21 098/188: Bump version, ELPA Syncer, 2024/05/05
- [elpa] externals/org-real e61d7ae333 102/188: Fully expand siblings when toggling global visibility, ELPA Syncer, 2024/05/05
- [elpa] externals/org-real c9a9646e2e 104/188: Relationship defaults to "in" if omitted in link, ELPA Syncer, 2024/05/05
- [elpa] externals/org-real 1e5434a318 107/188: Added popup library, ELPA Syncer, 2024/05/05
- [elpa] externals/org-real 00b02f8968 118/188: Reworked flexible layout, ELPA Syncer, 2024/05/05
- [elpa] externals/org-real d61adfc93b 103/188: Refactoring, ELPA Syncer, 2024/05/05
- [elpa] externals/org-real 99fb9277c1 116/188: Merge branch 'next' into 'main', ELPA Syncer, 2024/05/05
- [elpa] externals/org-real 25bfb06ad3 126/188: Adding margin and padding tests, ELPA Syncer, 2024/05/05
- [elpa] externals/org-real 0f7c7db1e1 128/188: Linting/documentation, ELPA Syncer, 2024/05/05
- [elpa] externals/org-real 47d52107b2 111/188: Refactoring; killing org real buffer if it exists before recreating,
ELPA Syncer <=
- [elpa] externals/org-real e9e0b15c37 125/188: Smooth lines, ELPA Syncer, 2024/05/05
- [elpa] externals/org-real 0b2acfac23 112/188: If headline is a link, only display description, ELPA Syncer, 2024/05/05
- [elpa] externals/org-real 9e6a98aab6 117/188: Jump to location when entering org real mode, ELPA Syncer, 2024/05/05
- [elpa] externals/org-real f9b38899b4 131/188: Added help-echo slot for minibuffer messages, ELPA Syncer, 2024/05/05
- [elpa] externals/org-real 47b638ba07 133/188: Linting/elc, ELPA Syncer, 2024/05/05
- [elpa] externals/org-real 655e8a7613 136/188: Bump version, ELPA Syncer, 2024/05/05
- [elpa] externals/org-real 69bfbae1cd 140/188: Color theme update, ELPA Syncer, 2024/05/05
- [elpa] externals/org-real e94d133e8a 144/188: Linting, ELPA Syncer, 2024/05/05
- [elpa] externals/org-real e6e9ac4146 154/188: Updated readme, ELPA Syncer, 2024/05/05
- [elpa] externals/org-real c65ece93df 155/188: Added elpaignore, ELPA Syncer, 2024/05/05