[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/focus 19b3c7b348 70/82: Just use a face for customizing th
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/focus 19b3c7b348 70/82: Just use a face for customizing the unfocused region |
Date: |
Tue, 6 Sep 2022 04:58:58 -0400 (EDT) |
branch: elpa/focus
commit 19b3c7b3487e4897cb37f135ff446799986b8a49
Author: Lars Tveito <larstvei@ifi.uio.no>
Commit: Lars Tveito <larstvei@ifi.uio.no>
Just use a face for customizing the unfocused region
Use font-lock-comment-face as a default. Maybe this fixes #21?
---
focus.el | 45 +++------------------------------------------
1 file changed, 3 insertions(+), 42 deletions(-)
diff --git a/focus.el b/focus.el
index 58b6a9e508..64d46617b4 100644
--- a/focus.el
+++ b/focus.el
@@ -38,17 +38,6 @@
:group 'font-lock
:prefix "focus-")
-(defcustom focus-dimness 0
- "Amount of dimness in out of focus sections is determined by this integer.
-
-A positive value increases the dimness of the sections.
-A negative value decreases the dimness.
-
-The default is 0 which means a 50/50 mixture of the background
-and foreground color."
- :type '(integer)
- :group 'focus)
-
(defcustom focus-mode-to-thing '((prog-mode . defun) (text-mode . sentence))
"An associated list between mode and thing.
@@ -73,7 +62,7 @@ Things that are defined include `symbol', `list', `sexp',
(defvar focus-cursor-type cursor-type
"Used to restore the users `cursor-type'")
-(defvar focus-dim-color nil
+(defvar focus-unfocused-face font-lock-comment-face
"Overrides the color used for dimmed text.")
(defvar-local focus-current-thing nil
@@ -105,28 +94,6 @@ The timer calls `focus-read-only-hide-cursor' after
"Return the current bounds, based on `focus-get-thing'."
(bounds-of-thing-at-point (focus-get-thing)))
-(defun focus-average-colors (color &rest colors)
- "Takes an average of the colors given by argument.
-Argument COLOR is a color name, and so are the COLORS; COLOR is
-there to ensure that the the function receives at least one
-argument."
- (let* ((colors (cons color colors))
- (colors (mapcar 'color-name-to-rgb colors))
- (len (length colors))
- (sums (apply 'cl-mapcar '+ colors))
- (avg (mapcar (lambda (v) (/ v len)) sums)))
- (apply 'color-rgb-to-hex avg)))
-
-(defun focus-make-dim-color ()
- "Return a dimmed color relative to the current theme."
- (let ((background (face-attribute 'default :background))
- (foreground (face-attribute 'default :foreground))
- (backgrounds (if (> focus-dimness 0) focus-dimness 1))
- (foregrounds (if (< focus-dimness 0) (- focus-dimness) 1)))
- (apply 'focus-average-colors
- (append (make-list backgrounds background)
- (make-list foregrounds foreground)))))
-
(defun focus-move-focus ()
"Move the focused section according to `focus-bounds'.
@@ -152,9 +119,8 @@ adds `focus-move-focus' to `post-command-hook'."
(setq focus-pre-overlay (make-overlay (point-min) (point-min))
focus-post-overlay (make-overlay (point-max) (point-max))
focus-buffer (current-buffer))
- (let ((color (or focus-dim-color (focus-make-dim-color))))
- (mapc (lambda (o) (overlay-put o 'face (cons 'foreground-color color)))
- (list focus-pre-overlay focus-post-overlay)))
+ (mapc (lambda (o) (overlay-put o 'face focus-unfocused-face))
+ (list focus-pre-overlay focus-post-overlay))
(add-hook 'post-command-hook 'focus-move-focus nil t)
(add-hook 'change-major-mode-hook 'focus-terminate nil t)))
@@ -276,11 +242,6 @@ It cleans up the `focus-read-only-blink-timer' and hooks."
:keymap (let ((map (make-sparse-keymap)))
(define-key map (kbd "C-c C-q") 'focus-read-only-mode)
map)
- (unless (or (and (color-defined-p (face-attribute 'default :background))
- (color-defined-p (face-attribute 'default :foreground)))
- focus-dim-color)
- (message "Can't enable focus mode when no theme is loaded. Try setting
focus-dim-color!")
- (setq focus-mode nil))
(if focus-mode (focus-init) (focus-terminate)))
;;;###autoload
- [nongnu] elpa/focus abad47f1c4 53/82: Add functions to pin/unpin the focused section, (continued)
- [nongnu] elpa/focus abad47f1c4 53/82: Add functions to pin/unpin the focused section, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 3a2c4f1198 67/82: Merge pull request #19 from jcs-PR/master, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus a723f78dc4 37/82: Added function for hiding the cursor, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus d5631db0b6 73/82: Remove `face`-suffix from faces, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 5bddbbb7d3 22/82: Remove newline, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus cfb1672fca 76/82: Merge pull request #22 from larstvei/focus-face, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus ffd97a5a36 56/82: Fix bug related to `post-command-hook`, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 045ee6175e 63/82: Remove focus-any and simply apply derived-mode-p, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 0f2a9945e9 66/82: Fixed some flycheck warnings., ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 1423efbd25 42/82: Don't assume bounds are found, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 19b3c7b348 70/82: Just use a face for customizing the unfocused region,
ELPA Syncer <=
- [nongnu] elpa/focus bfb6aaf8ad 57/82: Don't persist focus mode across major mode change, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus a84ade00a2 61/82: Addresses #13, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus f193014150 15/82: Did not work, back to static width, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus ef5f7fc892 45/82: Cleaned up `focus-next-thing' and `focus-prev-thing', ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus e9e841aed4 78/82: Remove sentence, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus f058bd163d 64/82: Fixed compile warnings., ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 5f3f20e7f2 80/82: Bump version, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 155da77a32 60/82: Fixes #14, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus cbba87b062 74/82: Trim candidate list of *things*, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 0a6e9624ea 49/82: Allow for changing the current thing interactively, ELPA Syncer, 2022/09/06