reddit / emacs

Resize/recolour text on-the-fly

moseswithhisbooks · 2022-06-13 01:02
moseswithhisbooks · 2022-06-13 01:04
When sharing screenshots, sometimes I want to emphasize some text, either by changing its colour or its size. This is easy to do in GoogleDocs or MicrosoftWord; so I mimicked those approaches for use in Emacs.
Kefim_Wod · 2022-06-13 02:08
Neat! That's a useful function. My only suggestion is to swap out `helm-colors` for `read-color` which is a built-in function and doesn't require `helm`.
crlsh · 2022-06-13 02:54
transcribed code with read-color included (no helm) ``` (defalias'my/resize-region'my/color-region) (cl-defun my/color-region(beg end &optional(color "blue")(size 300)) "Resize/recolour selected region;defaulting to blue at size 300,for titles. When invoked withaprefix,let uses select colour fromapalette and inputasize. Note gray80 at size 10 is useful for side remarks." (interactive"r") (when current-prefix-arg (setq color(read-color)) (setq size(read-number"Size:"))) (-let[contents(buffer-substring-no-properties beg end)] (delete-region beg end) (insert(propertize contents'font-lock-face `(:foreground ,color :height ,size))))) ``` Same idea, make the text invisible with a search and using overlay (no text properties), src :[Add invisible text property in org-mode - Emacs Stack Exchange](https://emacs.stackexchange.com/questions/70016/add-invisible-text-property-in-org-mode) ``` (defun my-make-invisible (my-re) (interactive "sRE Search Term: ") (save-excursion (goto-char (point-min)) (while (re-search-forward my-re nil t) (setq invisible-overlay (make-overlay (match-beginning 0) (match-end 0))) (overlay-put invisible-overlay 'invisible t)))) ```
mauguro_ · 2022-06-13 04:36
what theme are you using?
kovrik · 2022-06-13 22:33
Not op, but looks like Molokai to me: https://emacsthemes.com/themes/molokai-theme.html