Skip to content

REFACTOR: Fringe management #284

Description

@gggion

While trying to debug why fringes where being lost when doing buffer-revert on an org buffer with org-indent-mode active.
We've ended up with this unnecesarily abstracted set of functions related to fringe management.

;;; Helper Functions
(defun org-transclusion--fringe-spec-p (prop-value))
(defun org-transclusion--make-fringe-indicator (face))
(defun org-transclusion--update-line-prefix (line-beg line-end prop-name new-value))

;;;; Fringe Detection
(defun org-transclusion-prefix-has-fringe-p (prefix))

;;;; Fringe Creation
(defun org-transclusion-append-fringe-to-prefix (existing-prefix face))
(defun org-transclusion-add-fringe-to-region (buffer beg end face))

;;;; Fringe Removal
(defun org-transclusion-remove-fringe-from-prefix (prefix))
(defun org-transclusion-remove-fringe-from-region (buffer beg end))

I reckon these could be simplified and inlined, with the end results being:

;;; Neccesary helper functions
(defun org-transclusion--make-fringe-string (face))     ;; necesary abstraction so we only adjust/change  fringe chars in one place
(defun org-transclusion--prefix-has-fringe-p (prefix))  ;; better to track fringe detection outside of main functions

;;; creation and removal
(defun org-transclusion-add-fringes (buffer beg end face)) ;; adds fringes to region
(defun org-transclusion-remove-fringes (buffer beg end))   ;; removes fringes from region

Only further adjustments necesary will be changing the func name in the related functions where these are being called:

  • org-transclusion-content-add-text-props-and-overlay
  • org-transclusion-remove
  • org-transclusion-indent--reapply-all-fringes
  • org-transclusion-indent--add-properties-and-fringes
  • org-transclusion-indent--refresh-source-region

I've already begun refactoring and this seems like a likely final structure.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions