Skip to content

Instantly share code, notes, and snippets.

@Aneeqasif
Last active March 28, 2024 19:06
Show Gist options
  • Save Aneeqasif/7d9782cdd13d3b1e19f841e49a66c9b5 to your computer and use it in GitHub Desktop.
Save Aneeqasif/7d9782cdd13d3b1e19f841e49a66c9b5 to your computer and use it in GitHub Desktop.
org-mode Ui changes
(defun an/toggle-minor-mode (mode)
  (if (symbol-value mode) (funcall (symbol-function mode) 0) (funcall (symbol-function mode) 1)))


(defun an/writeroom-mode-specific ()
  (an/toggle-minor-mode 'display-line-numbers-mode)
  (an/toggle-minor-mode 'hl-line-mode))
                                        ; (add-hook 'writeroom-mode-hook #'an/writeroom-mode-specific)


(defun an/org-mode-visual-fill ()
  (setq visual-fill-column-width 110
        visual-fill-column-center-text t)
  (visual-fill-column-mode 1))

(use-package visual-fill-column
  :hook (org-mode . an/org-mode-visual-fill))

(after! writeroom-mode
  (setq! +zen-text-scale 0)
  (setq! writeroom-width 105)
  )

;; (add-hook 'org-mode-hook 'auto-save-visited-mode)
(remove-hook! org-mode #'flyspell-mode)

(with-eval-after-load 'org
  (dolist (face '((org-level-1 . 1.3)
                  (org-level-2 . 1.2)
                  (org-level-3 . 1.1)
                  (org-level-4 . 1.05)
                  (org-level-5 . 1.1)
                  (org-level-6 . 1.1)
                  (org-level-7 . 1.1)
                  (org-level-8 . 1.1)))
    (set-face-attribute (car face) nil  :weight 'bold :height (cdr face))))

;; (setq org-agenda-current-time-string "ᐊ―――――――――― now―――――――――― ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅")
(setq org-agenda-current-time-string "ᐊ――――― now――――――――")


(custom-set-faces
 '(org-agenda-current-time ((t ( :inherit 'doom-modeline-evil-normal-state  :height 1.09 ))))
 )


(use-package org
  ;; :ensure org-plus-contrib
  :hook (org-mode . mixed-pitch-mode)
  :hook (org-mode . variable-pitch-mode)
  :hook (org-mode . (lambda () (display-line-numbers-mode -1)))
  :bind
  (:map org-mode-map
        ("M-n" . org-next-visible-heading)
        ("M-m" . org-previous-visible-heading))
  :config
  :init
  )





(after! org


  (setq org-ellipsis "") ;;▾
  (setq! org-startup-with-inline-images 't)
  (setq org-hide-emphasis-markers t)
  (setq org-blank-before-new-entry '((heading . t) (plain-list-item . auto)))
  (setq org-agenda-start-on-weekday nil)
  (setq org-agenda-start-day "-0d"
        org-agenda-span 8)

  (setq org-habit-graph-column 100
        +org-habit-graph-padding 12)
  (setq! org-file-apps '((remote . emacs)
                         (auto-mode . emacs)
                         (directory . emacs)
                         ("\\.mm\\'" . default)
                         ("\\.x?html?\\'" . default)
                         ("\\.pdf\\'" . "sioyek %s")))

  (setq org-agenda-start-with-log-mode t
        org-deadline-warning-days 8
        org-log-done 'time
        org-agenda-breadcrumbs-separator ""
        org-log-into-drawer t)

;;;;;

  (setq org-priority-faces
        '((65 :foreground "#e45649")
          (66 :foreground "#0098dd")
          (67 :foreground "spring green")))

  (setq org-todo-keywords
        '((sequence
           "TODO(t)" ; A task that needs doing & is ready to do
           "NEXT(n)" ; Task is in progress
           "ACTIVE(a)"
           "|"
           "DONE(d)")

          (sequence
           "IDEA(i)"
           "GOAL(g)"
           "REVIEW(v)"
           "PROG(p)"
           "WAIT(w)" ; Something external is holding up this task
           "HOLD(h)"
           "|"
           "[COMPLETED](c)"
           "CANC(X@/!)")

          (sequence
           "SOMEDAY(m)")
          (sequence
           "TOREAD(r)"
           "RDING"
           "RDNOTE"
           "TMPDROP"
           "|"
           "DROP"
           "FINISHED"))

        org-todo-keyword-faces
        '(("IDEA"     . +org-todo-active)
          ("NEXT"     .  hydra-face-blue)
          ("WAITING"  . +org-todo-onhold)
          ("CANCELED" . +org-todo-cancel)
          ("SOMEDAY"  . (:foreground ,(face-foreground 'ansi-color-green)  :weight bold))
          ("DONE"     . (:foreground ,(face-foreground 'line-number)       :weight bold))
          ("ACTIVE"   . +org-todo-active)
          ))
  (setq org-priority-default ?C)


  )

(setq org-fancy-priorities-list  '("󰻃" "" "")) ;; 󰝥 ●  󰻃

(require 'org-habit)
(require 'org-checklist)
(add-to-list 'org-modules 'org-habit)
(add-to-list 'org-modules 'org-checklist)

(setq org-tag-alist
      '((:startgroup)      ;; Put mutually exclusive tags here
        ("urgent" . ?u)
        ("imp" . ?i)
        (:endgroup)
        ("health" . ?h)
        ("work" . ?w)
        ("study" . ?w)
        ("planning" . ?p)
        ("idea" . ?i)))

(setq org-tag-faces
      '(
        ("urgent" . (:foreground "GoldenRod" :weight bold))
        )
      )



(setq org-refile-targets
      '(
        ("archive.org" :maxlevel . 1)
        (nil :maxlevel . 3) ;; here nill means all headings of current file
        ;; (,(directory-files-recursively "~/Sync/org/" "^[a-z0-9]*.org$") :maxlevel . 1)
        (org-agenda-files :maxlevel . 3)
        ))

(defun an-org-refile-candidates ()
  (directory-files-recursively "/home/aneeq/Sync/org"  ".*\\.org$"))
(add-to-list 'org-refile-targets '(an-org-refile-candidates :maxlevel . 3))

Org-mode Ui enhancement

(defun my/prettify-symbols-setup ()
  "Beautify keywords"
  (setq prettify-symbols-alist
        (mapcan (lambda (x) (list x (cons (upcase (car x)) (cdr x))))
                '(; Greek symbols
                  ("lambda" . )
                  ("psi"    . )
                                        ; Org headers
                  ("#+title:"  . "")
                  ("#+author:" . "")
                                        ; Checkboxes
                  ("[ ]" . "")
                  ("[X]" . "") ;;"󰄵"
                  ("[-]" . "" )
                                        ; Blocks
                  ("#+begin_src"   . "") ;
                  ("#+end_src"     . "") ;
                  ("#+begin_QUOTE" . "")
                  ("#+begin_QUOTE" . "")
                                        ; Drawers
                                        ;    ⚙️
                  (":properties:" . "")
                                        ; Agenda scheduling
                                        ; Agenda tags  
                  (":@thesis:"    . "📝")
                  ("#+filetags:"  . "🏷️")
                  )))
  (prettify-symbols-mode))

(add-hook 'org-mode-hook        #'my/prettify-symbols-setup)
(add-hook 'org-agenda-mode-hook #'my/prettify-symbols-setup)


(font-lock-add-keywords 'org-mode
                        '(("^ *\\([-]\\) "
                           (0 (prog1 () (compose-region (match-beginning 1) (match-end 1) ""))))))


(add-to-list 'font-lock-extra-managed-props 'display)

;; always right allight the tags


;; (font-lock-add-keywords 'org-mode
;;         '(("^ *\\([-]\\) "
;;           (0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "•"))))))


(after! org

  (font-lock-add-keywords 'org-mode
                          `(("^.*?\\( \\)\\(:[[:alnum:]_@#%:]+:\\)$"
                             (1 `(face nil
                                  display (space :align-to (- right ,(org-string-width
                                                                      (match-string 2)) 3)))
                                prepend))) t)

  (defvar-local my-icon-dir (concat doom-user-dir "assets/")
    "directory withthe icons for agenda view category icons")
  (setq org-agenda-category-icon-alist
        `(
          ;; ("index" ,(concat my-icon-dir "epub.png") nil nil
          ;;  :ascent center :height 25 :width 25 )

          ;; ("habits" ,(concat my-icon-dir "synfig_icon.png") nil nil
          ;;  :ascent center :height 25 :width 25 )

          ))

  )

(use-package org-agenda-category-icons
  :after org
  :config
        (org-agenda-category-icons!
        ;; Set the icon for the category "sleep" to the faicon "bed" icon from
        ;; `all-the-icons'
        :faicon
        (bed sleep)

        :octicon
        (check done)

        :material
        (local_car_wash "Car Wash") ;; multi-word categories should be in a string

        :emoji
        ("🏋" Workout workouts) ;; define multiple categories

     )
  )

SVG Tag mode

(defun an-org-agenda-show-svg ()
  (let* ((case-fold-search nil)
         (keywords (mapcar #'svg-tag--build-keywords svg-tag--active-tags))
         (keyword (car keywords)))
    (while keyword
      (save-excursion
        (while (re-search-forward (nth 0 keyword) nil t)
          (overlay-put (make-overlay
                        (match-beginning 0) (match-end 0))
                       'display  (nth 3 (eval (nth 2 keyword)))) ))
      (pop keywords)
      (setq keyword (car keywords)))))

(use-package svg-tag-mode
  :after org
  :config


  :init

  (defconst date-re "[0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}")
  (defconst time-re "[0-9]\\{2\\}:[0-9]\\{2\\}")
  (defconst day-re "[A-Za-z]\\{3\\}")
  (defconst day-time-re (format "\\(%s\\)? ?\\(%s\\)?" day-re time-re))

  (defface pastelinpurple '((t (:inherit org-todo :height 2.0 :foreground "#957DAD"))) "Face for todo")
  (defface pastelgreen '((t (:inherit org-todo :height 2.0 :foreground "#B0EB93"))) "Face for WIP")
  (defface pastelblue '((t (:inherit org-todo :height 2.0 :foreground "#B3E3DA"))) "Face for DONE")
  (defface pastelred '((t (:inherit org-todo :height 2.0 :foreground "#F98284"))) "Face for tags")
  (defface pastelpink '((t (:inherit org-todo :height 2.0 :foreground "#FEAAE4"))) "Face for Date")
  (defface incyan '((t (:inherit org-todo :height 2.0 :foreground "#00b3b3"))) "Face for Code")
  (defface incobolt '((t (:inherit org-todo :height 2.0 :foreground "#0099cc"))) "Face for Verbatim")
  (defface inyellow '((t (:inherit org-todo :height 2.0 :foreground "#fff7a0"))) "Face ")
  (defface inpurple '((t (:inherit org-todo :height 2.0 :foreground "#bc8dff"))) "Face  Files")
  (defface inpurple-note '((t (:inherit org-todo :height 2.0 :foreground "#8977c9"))) "Face for NOTE")
  (defface inpurple-note-early '((t (:inherit org-todo :height 2.0 :foreground "#3c4059"))) "Face")


  (setq svg-tag-tags `(

                       ;; Active date (with or without day name, with or without time)
                       (,(format "\\(<%s>\\)" date-re) .
                        ((lambda (tag)
                           (svg-tag-make tag :beg 1 :end -1 :margin 0))))

                       (,(format "\\(<%s \\)%s>" date-re day-time-re) .
                        ((lambda (tag)
                           (svg-tag-make tag :beg 1 :inverse nil :crop-right t :margin 0))))

                       (,(format "<%s \\(%s>\\)" date-re day-time-re) .
                        ((lambda (tag)
                           (svg-tag-make tag :end -1 :inverse t :crop-left t :margin 0))))

                       ;; Inactive date  (with or without day name, with or without time)
                       (,(format "\\(\\[%s\\]\\)" date-re) .
                        ((lambda (tag)
                           (svg-tag-make tag :beg 1 :end -1 :margin 0 :face 'org-date))))

                       (,(format "\\(\\[%s \\)%s\\]" date-re day-time-re) .
                        ((lambda (tag)
                           (svg-tag-make tag :beg 1
                                         :inverse nil :crop-right t
                                         :margin 0 :face 'org-date))))

                       (,(format "\\[%s \\(%s\\]\\)" date-re day-time-re) .
                        ((lambda (tag)
                           (svg-tag-make tag :end -1
                                         :inverse t :crop-left t
                                         :margin 0 :face 'org-date))))

                       ("PROJ" . ((lambda (tag)
                                    (svg-tag-make tag :face 'org-todo :inverse t :margin 0))))
                       ("TODO" . ((lambda (tag)
                                    (svg-tag-make tag :face 'org-todo :inverse t :margin 0))))
                       ("DONE" . ((lambda (tag)
                                    (svg-tag-make tag :face 'org-done :inverse t :margin 0))))
                       ("CANC" . ((lambda (tag)
                                        (svg-tag-make "CANC" :face 'error :inverse t :margin 0))))
                       ("ACTIVE" . ((lambda (tag)
                                      (svg-tag-make tag :face '+org-todo-active :inverse t :margin 0))))
                       ("REVIEW" . ((lambda (tag)
                                      (svg-tag-make tag :face 'font-lock-keyword-face
                                                    :inverse t :margin 0))))
                       ("IDEA" . ((lambda (tag)
                                      (svg-tag-make tag :face '+org-todo-active :inverse t :margin 0))))
                       ("NEXT" . ((lambda (tag)
                                    (svg-tag-make tag :face 'org-todo :inverse t :margin 0))))

                       ("WAIT" . ((lambda (tag)
                                    (svg-tag-make tag :face 'org-warning :inverse t :margin 0))))




                       ("\\(#\\+[A-Za-z0-9#]+:\\)" . ((lambda (tag)
                                                     (svg-tag-make tag
                                                             :face 'svg-lib-button-press-face :beg 1
                                                             :end -1 :inverse t))))

                       ("\\(:[a-zA-Z#0-9]+:\\)" . ((lambda (tag)
                                                     (svg-tag-make tag
                                                             :face 'svg-lib-button-press-face :beg 1
                                                             :end -1 :inverse t))))

                       ("\\(:[a-zA-Z]+\\)\|[a-zA-Z#0-9]+:" . ((lambda (tag)
                                                         (svg-tag-make tag :beg 1 :inverse t
                                                               :face 'svg-lib-button-press-face
                                                               :margin 0 :crop-right t))))
                       (":[a-zA-Z]+\\(:[a-zA-Z#0-9]+:\\)" . ((lambda (tag)
                                                             (svg-tag-make tag :beg 1 :end -1
                                                               :face 'svg-lib-button-press-face
                                                                           :margin 0
                                                                           crop-left t))))
                       ;; Task priority
                       ("\\[#[A-Z]\\]" . ( (lambda (tag)
                                             (svg-tag-make tag :face 'org-priority :inverse t
                                                           :beg 2 :end -1 :margin 0))))


;; :FIXME| This needs to be fixed
;; :HACK|Fix this regexp
;; :FIX|TJere os more regexp
;; :HACK|Insert text here
;; :NOTE|Here is a test

("\\([:]\\{1\\}\\W?\\(?:FIXME\\|Fixme\\)|.*\\)" . ((lambda (tag) (svg-tag-make tag
                :face 'incyan
                                         :inverse t
                                         :crop-left t
              :beg 7))))

("\\([:]\\{1\\}\\W?\\(?:FIX\\|Fix\\)|.*\\)" . ((lambda (tag) (svg-tag-make tag
              :face 'incyan
                                         :inverse t
                                         :crop-left t
              :beg 5))))

("\\([:]\\{1\\}\\W?\\(?:HACK\\|PERF\\|MARK\\|Hack\\)*|.*\\)" . ((lambda (tag) (svg-tag-make tag
                 :face 'incyan
                                                 :inverse t
                                          :crop-left t
                 :beg 6))))
("\\([:]\\{1\\}\\W?\\(?:NOTE\\|Note\\)*|.*\\)" . ((lambda (tag) (svg-tag-make tag
           :face 'incyan
                          :inverse t
                          :crop-left t
           :beg 6))))


("\\([:]\\{1\\}\\W?\\(?:Note\\|NOTE\\)*|\\)" . ((lambda (tag) (svg-tag-make tag
                 :face 'incyan
       :inverse nil
                 :margin 0
                 :crop-right t
       :beg 1
       :end -1))))


("\\([:]\\{1\\}\\W?\\(?:HACK\\|Hack\\|PERF\\|FIXME\\|Fixme\\|FIX\\|Fix\\|MARK\\)*|\\)" . ((lambda (tag) (svg-tag-make tag
                                                                                 :face 'incyan
                               :inverse nil
                                                                                 :margin 0
                                                                                 :crop-right t
                               :beg 1
                               :end -1))))


;; Org TAGS
          (":TODO:" . ((lambda (tag) (svg-tag-make "TODO" :inverse t :face 'pastelinpurple))))
          ;; (":PROPERTIES:" . ((lambda (tag) (svg-tag-make "PROPERTIES" :inverse t :face 'inpurple))))
          ("SCHEDULED:" . ((lambda (tag) (svg-tag-make "SCHEDULED" :inverse t :face 'incobolt))))
          ("DEADLINE:" . ((lambda (tag) (svg-tag-make "DEADLINE" :inverse t :face 'incobolt))))
          ;; ("#+author:" . ((lambda (tag) (svg-tag-make "AUTHOR" :inverse t :face 'incobolt))))
          ;; ("+date:" . ((lambda (tag) (svg-tag-make "DATE" :inverse t :face 'incobolt))))
          ;; ("+OPTIONS:" . ((lambda (tag) (svg-tag-make "OPTIONS" :face 'incobolt))))
          ;; ("#+STARTUP" . ((lambda (tag) (svg-tag-make "STARTUP" :inverse t :face 'incobolt))))
          ;;  ("+RESULTS:" . ((lambda (tag) (svg-tag-make "RESULTS" :inverse t :face 'cobolt))))
          ;; ("+CAPTION:" . ((lambda (tag) (svg-tag-make "CAPTION" :inverse t :face 'incyan))))
          ;; ("+NAME:" . ((lambda (tag) (svg-tag-make "NAME" :inverse t :face 'incyan))))
          (":ID:" . ((lambda (tag) (svg-tag-make "ID" :face 'inpurple))))
          (":END:" . ((lambda (tag) (svg-tag-make "END" :inverse t :face 'inpurple))))

          ;; Active date (with or without day name, with or without time)
          ;; <2023-04-03 Sun 17:45>
        (,(format "\\(<%s>\\)" date-re) .
         ((lambda (tag)
            (svg-tag-make tag :beg 1 :end -1 :margin 0))))
        (,(format "\\(<%s \\)%s>" date-re day-time-re) .
         ((lambda (tag)
            (svg-tag-make tag :beg 1 :inverse t :crop-right t :margin 0 :face 'org-date))))
        (,(format "<%s \\(%s>\\)" date-re day-time-re) .
         ((lambda (tag)
            (svg-tag-make tag :end -1 :inverse nil :crop-left t :margin 0 :face 'org-date))))



        ;; Inactive date  (with or without day name, with or without time)
        ;; [2023-04-03 Sun 17:45]
         (,(format "\\(\\[%s\\]\\)" date-re) .
          ((lambda (tag)
             (svg-tag-make tag :beg 1 :end -1 :margin 0 :face 'org-date))))
         (,(format "\\(\\[%s \\)%s\\]" date-re day-time-re) .
          ((lambda (tag)
             (svg-tag-make tag :beg 1 :inverse nil :crop-right t :margin 0 :face 'org-agenda-date))))
         (,(format "\\[%s \\(%s\\]\\)" date-re day-time-re) .
          ((lambda (tag)
             (svg-tag-make tag :end -1 :inverse t :crop-left t :margin 0 :face 'org-agenda-date))))

                       ))
  :hook
  (org-mode . svg-tag-mode)
  (org-agenda-finalize-hook . #'an-org-agenda-show-svg)

)

(setq doom-font (font-spec :family "Iosevka NFM" :size 22 )
      doom-big-font (font-spec :family "Iosevka NFM" :size 22 )
      doom-symbol-font (font-spec :family "Iosevka NFP" :size 27 )
      doom-serif-font (font-spec :family "Libre Baskerville" :size 22 )
      doom-variable-pitch-font (font-spec :family "Concourse T4 Tab" :size 27))

;; Equity Text A ;; Concourse T4 ;; lato ;; Concourse T3 Tab ;;Crimson Pro
;; Noto Serif ;; DejaVuSerifCondensed Nerd Font

;;Source Serif Pro / Alegreya /Caveat Brush /Barlow Condensed/Roboto Condensed/DejaVuSerifCondensed Nerd Font

(custom-theme-set-faces
 'user
 '(org-block ((t (:inherit fixed-pitch))))
 '(org-code ((t (:inherit (shadow fixed-pitch)))))
 '(org-document-info-keyword ((t (:inherit (shadow fixed-pitch)))))
 '(org-indent ((t (:inherit (org-hide fixed-pitch)))))
 '(org-link ((t ( :underline t))))
 '(org-meta-line ((t (:inherit (font-lock-comment-face fixed-pitch)))))
 '(org-property-value ((t (:inherit fixed-pitch))) t)
 '(org-special-keyword ((t (:inherit (font-lock-comment-face fixed-pitch)))))
 '(org-table ((t (:inherit fixed-pitch ))))
 '(org-tag ((t (:inherit (shadow fixed-pitch) :weight bold :height 0.8))))
 '(org-verbatim ((t (:inherit (shadow fixed-pitch))))))

@Aneeqasif
Copy link
Author

some of this may not work like the code block

(font-lock-add-keywords 'org-mode
                          `(("^.*?\\( \\)\\(:[[:alnum:]_@#%:]+:\\)$"
                             (1 `(face nil
                                  display (space :align-to (- right ,(org-string-width
                                                                      (match-string 2)) 3)))
                                prepend))) t)

donot work in doom emacs if other minor modes that come with org +pretty module llike superstartmode especially are enabled

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