[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org-remark 89ee82935c 14/75: fix: window margins do not
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org-remark 89ee82935c 14/75: fix: window margins do not persist |
Date: |
Fri, 6 Oct 2023 12:59:16 -0400 (EDT) |
branch: externals/org-remark
commit 89ee82935ca9eb68535b4b05d63a4fe0292ca7d8
Author: Noboru Ota <me@nobiot.com>
Commit: Noboru Ota <me@nobiot.com>
fix: window margins do not persist
Adapt the way Olivetti does it.
---
org-remark-line.el | 59 +++++++++++++++++++++++++++++++++++++++++-------------
org-remark.el | 2 ++
2 files changed, 47 insertions(+), 14 deletions(-)
diff --git a/org-remark-line.el b/org-remark-line.el
index 93b118f857..9e3ad39c51 100644
--- a/org-remark-line.el
+++ b/org-remark-line.el
@@ -45,6 +45,47 @@
(defvar org-remark-line-ellipsis "…")
+;;;###autoload
+(define-minor-mode org-remark-line-mode
+ "Enable Org-remark to highlight and annotate the whole line."
+ :global nil
+ :group 'org-remark
+ (if org-remark-line-mode
+ ;; Enable
+ (progn
+ ;; Depth is deeper than the default one for range highlight.
+ ;; This is to prioritize it over line-highlight when the fomer
+ ;; is at point and yet on the same line of another
+ ;; line-highlight.
+ (add-hook 'org-remark-find-dwim-functions
+ #'org-remark-line-find 80 :local)
+ (add-hook 'window-size-change-functions
+ #'org-remark-line-set-window-margins nil :local)
+ ;; (add-hook 'text-scale-mode-hook
+ ;; #'org-remark-line-set-buffer-windows nil :local)
+ (org-remark-line-set-buffer-windows))
+ (remove-hook 'org-remark-find-dwim-functions #'org-remark-line-find :local)
+ (remove-hook 'window-size-change-functions
+ #'org-remark-line-set-window-margins :local)
+ (remove-hook 'text-scale-mode-hook
+ #'org-remark-line-set-buffer-windows :local)))
+
+(defun org-remark-line-set-buffer-windows ()
+ "
+Adapted from Olivetti mode"
+ (mapc #'org-remark-line-set-window-margins
+ (get-buffer-window-list nil nil 'visible)))
+
+(defun org-remark-line-set-window-margins (window-or-frame)
+ "Set the margins of current window that displays current buffer.
+Return a cons of the form (LEFT-WIDTH . RIGHT-WIDTH). If a
+marginal area does not exist, its width will be returned as nil."
+ (when (and (windowp window-or-frame) org-remark-line-mode)
+ (cl-destructuring-bind (left-width . right-width) (window-margins)
+ (when (or (eq left-width nil) (< left-width 3))
+ (set-window-margins nil 3))
+ (window-margins))))
+
(defun org-remark-line-pos-bol (pos)
"Return the beginning of the line position for POS."
(save-excursion
@@ -66,14 +107,6 @@ by `overlays-in'."
(highlights (overlays-in bol bol)))
(seq-find #'org-remark-line-highlight-p highlights)))
-;; Depth is deeper than the default one for range highlight. This is to
-;; prioritize it over line-highlight when the fomer is at point and yet
-;; on the same line of another line-highlight.
-(add-hook 'org-remark-find-dwim-functions #'org-remark-line-find 80)
-
-(add-hook 'window-size-change-functions
- #'(lambda (&rest args)
- (set-window-margins nil 2)))
;;;###autoload
;; (defun org-remark-mark-line (beg end &optional id mode)
@@ -100,13 +133,11 @@ by `overlays-in'."
(defun org-remark-line-highlight-overlay-put (ov face &optional string)
(let* ((face (or face 'org-remark-line-highlighter))
- (left-margin (or (car (window-margins))
- ;; when nil = no margin, set to 1
- (progn (set-window-margins nil 2)
- 2)))
- (spaces (- left-margin 2))
+ (left-margin (car (org-remark-line-set-window-margins
+ (get-buffer-window))))
+ ;;(spaces (- left-margin 1))
(string (or string
- (with-temp-buffer (insert-char ?\s spaces)
+ (with-temp-buffer ;;(insert-char ?\s spaces)
(insert org-remark-line-icon)
(buffer-string)))))
(overlay-put ov 'before-string (propertize "! " 'display
diff --git a/org-remark.el b/org-remark.el
index 84679aabcf..6b5e95dcc9 100644
--- a/org-remark.el
+++ b/org-remark.el
@@ -315,6 +315,7 @@ recommended to turn it on as part of Emacs initialization.
(org-remark-mode
;; Activate
(org-remark-icon-mode +1) ;; automatically enabled by default
+ (org-remark-line-mode +1)
(org-remark-highlights-load)
(add-hook 'after-save-hook #'org-remark-save nil t)
(add-hook 'org-remark-highlight-link-to-source-functions
@@ -328,6 +329,7 @@ recommended to turn it on as part of Emacs initialization.
(delete-overlay highlight)))
(setq org-remark-highlights nil)
(org-remark-icon-mode -1)
+ (org-remark-line-mode -1)
(remove-hook 'after-save-hook #'org-remark-save t)
(remove-hook 'org-remark-highlight-link-to-source-functions
#'org-remark-highlight-link-to-source-default)
- [elpa] externals/org-remark 6b4c196f86 12/75: feat: icon for line highlight, (continued)
- [elpa] externals/org-remark 6b4c196f86 12/75: feat: icon for line highlight, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 3a9884e5df 26/75: fix(line): When buffer is first created, window may not be created, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 199702118a 30/75: fix(line): Disable line-mode should disable the margins, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 447fc2beaf 04/75: feat(line): highlight level headline text, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark ded8fddddd 01/75: initial prototype to explore what needs to change, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 0f2bf566ee 10/75: docs(info): source comments, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark f679d00c0a 06/75: refactor(line): loading and renaming the el file, ELPA Syncer, 2023/10/06
- [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 <=
- [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, 2023/10/06
- [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