help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Making a minor-mode for org-mode


From: uzibalqa
Subject: Making a minor-mode for org-mode
Date: Fri, 02 Jun 2023 16:59:22 +0000

I have this functionality associated with org-mode to change the appearance
of headings.  I would like the functionality inside a function that I can call
(let us say it is named komun-headings-tool)

;;;###autoload
(define-minor-mode komun-minor-mode
  "Provides teels for org-mode."
  nil nil nil

  (let*
      (($keyword
        `(("^\\*+ "
           (0 (let* ( ($kondor
                         (- (match-end 0) (match-beginning 0) 1))
                      ($inline-task
                         (and (boundp 'org-inlinetask-min-level)
                              (>= $kondor org-inlinetask-min-level))) )
                ;;--------------------------------------
                (compose-region (- (match-end 0) 2)
                                (- (match-end 0) 1)
                                (komun-shape-select $kondor))
               ;;---------------------------------------
               (when $inline-task
                  (compose-region (- (match-end 0) 3)
                                  (- (match-end 0) 2)
                                  (komun-shape-select $kondor)))
               ;;---------------------------------------
               (when (facep komun-typeface)
                  (put-text-property
                     (- (match-end 0) (if $inline-task 3 2))
                     (- (match-end 0) 1)
                     'face komun-typeface))
               ;;---------------------------------------
               (put-text-property
                  (match-beginning 0)
                  (- (match-end 0) 2)
                  'face (list :foreground
                        (face-attribute 'default :background)))
               ;;---------------------------------------
               (put-text-property (match-beginning 0)
                                  (match-end 0)
                                  'keymap komun-cyclehg-wmouse)
               ;;---------------------------------------
               nil )) ))))

    (if komun-signal

        (progn
          (font-lock-add-keywords nil $keyword)
          (font-lock-fontify-buffer))

      (save-excursion
        (goto-char (point-min))
        (font-lock-remove-keywords nil $keyword)
        (while (re-search-forward "^\\*+ " nil t)
          (decompose-region (match-beginning 0) (match-end 0)) )
        (font-lock-fontify-buffer)) ) ))








reply via email to

[Prev in Thread] Current Thread [Next in Thread]