Posts tagged "emacs":
Tag elements if there are any unread emails in your
(defconst ragone-unread-tag "unread" "Tag to add to Org elements which have unread emails.") (defun ragone-tag-unread-elements () "Update Org elements with `ragone-unread-tag' if there are unread emails." (unless (mu4e~proc-running-p) (mu4e~proc-start)) (org-map-entries (lambda () (let* ((search (concat "flag:unread " (nth 4 (org-heading-components)))) (code (with-temp-buffer (call-process "mu" nil (current-buffer) nil "find" search)))) (org-toggle-tag ragone-unread-tag (if (= 0 code) 'on 'off)))) t 'agenda)) ;; Add a hook to run before agenda displays. (add-hook 'org-agenda-mode-hook #'ragone-tag-unread-elements)
My initial buffer displays a random quote from a list of programming/CS quotes. The complete list of quotes can be found here.
(defvar ragone-quotes-file "~/.doom.d/quotes.txt" "File to lookup quotes.") (defvar ragone-quotes-file-seperator-regex "\n%\n" "Delimiter for seperating the line in `ragone-quotes-file'.") (defvar ragone-quotes-author-regex "^--" "Regex for getting the author of the quote. Anything after this will be changed to face `font-lock-comment-face'.") (defun ragone-get-quote (&optional nth) "Get a random quote from `ragone-quotes-file'. Optionally get the NTH quote." (let* ((quotes (split-string (with-temp-buffer (insert-file-contents ragone-quotes-file) (buffer-substring-no-properties (point-min) (point-max))) ragone-quotes-file-seperator-regex t)) (selected-quote (nth (or nth (random (length quotes))) quotes))) (put-text-property (string-match ragone-quotes-author-regex selected-quote) (length selected-quote) 'face 'font-lock-comment-face selected-quote) selected-quote)) ;; Update your scratch buffer (setq initial-scratch-message (ragone-get-quote))
For the past couple of months I have been working on tools which allow you
to run linters on the added/modified lines of a Git diff. One of these tools are
This is primarily meant to be used on legacy projects where you do not want to see errors for the whole file but only for the added/modified lines.
M-x magit-diff-flycheck in a magit-diff buffer to display a filtered list
of Flycheck errors for the added/modified lines only.
;; Run Flycheck on added/modified lines by default M-x magit-diff-flycheck
Use can also run the command with a prefix which will prompt you for the scope of the errors.
;; Choose scope of error filtering to symbol files or lines C-u M-x magit-diff-flycheck
Quickly copy an image of a htmlized buffer or region to the clipboard.
(defun ragone-htmlize () "Convert the htmlized region to an image and copy to clipboard." (interactive) (let ((htmlize-pre-style t) (region-background (face-attribute 'region :background)) (start (if (region-active-p) (region-beginning) (point-min))) (end (if (region-active-p) (region-end) (point-max)))) (set-face-background 'region "unspecified") (unwind-protect (ragone-htmlize-to-clipboard (htmlize-region-for-paste start end)) (set-face-background 'region region-background)))) (defun ragone-htmlize-to-clipboard (html) "Copy HTML to clipboard." (with-temp-buffer (insert html) (call-shell-region (point-min) (point-max) "wkhtmltoimage -f png - - | xclip -i -selection clipboard -t image/png")))
Easily toggle between your notes and your working buffer.
(defun ragone-kill-deft-buffers () "Toggle Deft mode." (interactive) (save-excursion (let ((count 0)) (dolist (buffer (buffer-list)) (set-buffer buffer) (when (not (eq nil deft-note-mode)) (setq count (1+ count)) (kill-buffer buffer)))))) (defun ragone-deft-or-close () "Kill all Deft buffers." (interactive) (if (or (eq major-mode 'deft-mode) (not (eq nil deft-note-mode))) (progn (ragone-kill-deft-buffers) (kill-buffer "*Deft*")) (deft)))