(defun mk-show-modeline () (interactive) (setq mode-line-format '(("-" mode-line-mule-info mode-line-modified mode-line-frame-identification mode-line-buffer-identification " " mode-line-position mode-line-modes (which-func-mode ("" which-func-format "--")) (global-mode-string ("--" global-mode-string)) "-%-"))) (defvar mode-line-format-current (symbol-value 'mode-line-format))) (defun mk-hide-modeline () (interactive) (setq mode-line-format nil)) (defun mk-write-mode-enable () (setq olivetti-body-width 73) (olivetti-mode) (mk-hide-modeline)) (defun mk-write-mode-disable () (olivetti-mode) (mk-show-modeline)) (defun me/split-windows-horizontal (count-windows) "Split windows horizontal by equal width." (interactive "nHow many splits? ") (delete-other-windows) (let ((width (/ (window-total-width) count-windows))) (dotimes (i (1- count-windows)) (split-window-right (- width))))) (defun me/split-windows-vertical (count-windows) "Split windows vertical by equal width." (interactive "nHow many splits? ") (delete-other-windows) (let ((height (/ (window-total-height) count-windows))) (dotimes (i (1- count-windows)) (split-window-below (- height))))) (defun me/split-h3 () (interactive) (me/split-windows-horizontal 3)) (defun me/split-v3 () (interactive) (me/split-windows-vertical 3)) ;; Set transparency of emacs (defun transparency (value) "Sets the transparency of the frame window. 0=transparent/100=opaque" (interactive "nTransparency Value 0 - 100 opaque: ") (set-frame-parameter (selected-frame) 'alpha value)) (defun start-irc (nick) (interactive "sTell me your nick please: ") (erc-tls :server "irc.libera.chat" :port 6697 :nick nick :full-name "emacs-user")) (defun me/org-copy-subtree-contents () "Get the content text of the subtree at point and add it to the `kill-ring'. Excludes the heading and any child subtrees." (interactive) (if (org-before-first-heading-p) (message "Not in or on an org heading") (save-excursion ;; If inside heading contents, move the point back to the heading ;; otherwise `org-agenda-get-some-entry-text' won't work. (unless (org-on-heading-p) (org-previous-visible-heading 1)) (let ((contents (substring-no-properties (org-agenda-get-some-entry-text (point-marker) most-positive-fixnum)))) (message "Copied: %s" contents) (kill-new contents))))) (defun jnf/magit-browse-pull-request () "In `magit-log-mode', open the associated pull request at point." (interactive) (let* ((remote-url (car (git-link--exec "remote" "get-url" (format "%s" (magit-get-current-remote))))) (beg (line-beginning-position)) (end (line-end-position)) (region (buffer-substring-no-properties beg end))) (save-match-data (and (string-match "(\\#\\([0-9]+\\))$" region) (browse-url-default-macosx-browser (concat (s-replace ".git" "" remote-url) "/pull/" (match-string 1 region))))))) ;; work with org-agenda dispatcher [c] "Today Clocked Tasks" to view today's clocked tasks. (defun org-agenda-log-mode-colorize-block () "Set different line spacing based on clock time duration." (save-excursion (let* ((colors (cl-case (alist-get 'background-mode (frame-parameters)) ('light (list "#d8dee9" "#e5e9f0" "#eceff4")) ('dark (list "#bf616a" "#d08770" "#ebcb8b" "#a3be8c" "#b48ead")))) pos duration) (nconc colors colors) (goto-char (point-min)) (while (setq pos (next-single-property-change (point) 'duration)) (goto-char pos) (when (and (not (equal pos (point-at-eol))) (setq duration (org-get-at-bol 'duration))) ;; larger duration bar height (let ((line-height (if (< duration 15) 1.0 (+ 0.5 (/ duration 30)))) (ov (make-overlay (point-at-bol) (1+ (point-at-eol))))) (overlay-put ov 'face `(:background ,(car colors) :foreground "black")) (setq colors (cdr colors)) (overlay-put ov 'line-height line-height) (overlay-put ov 'line-spacing (1- line-height)))))))) (add-hook 'org-agenda-finalize-hook #'org-agenda-log-mode-colorize-block)