[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/focus 0a6e9624ea 49/82: Allow for changing the current thi
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/focus 0a6e9624ea 49/82: Allow for changing the current thing interactively |
Date: |
Tue, 6 Sep 2022 04:58:57 -0400 (EDT) |
branch: elpa/focus
commit 0a6e9624ea5607dadd0f2cd4d3eaa2b10b788eb9
Author: Lars Tveito <larstvei@ifi.uio.no>
Commit: Lars Tveito <larstvei@ifi.uio.no>
Allow for changing the current thing interactively
The `focus-mode-to-thing` variable dictates what thing to use according
to the currently enabled mode. Changing this if you only wished to
change the thing for a single session seems tedious. Now this can be
achieved by `M-x focus-change-thing`.
---
focus.el | 32 ++++++++++++++++++++++++++------
1 file changed, 26 insertions(+), 6 deletions(-)
diff --git a/focus.el b/focus.el
index 46a7ad353e..3d492cf1f8 100644
--- a/focus.el
+++ b/focus.el
@@ -5,7 +5,7 @@
;; Author: Lars Tveito <larstvei@ifi.uio.no>
;; URL: http://github.com/larstvei/Focus
;; Created: 11th May 2015
-;; Version: 0.0.2
+;; Version: 0.1.0
;; Package-Requires: ((emacs "24") (cl-lib "0.5"))
;; This program is free software; you can redistribute it and/or modify
@@ -70,6 +70,9 @@ Things that are defined include `symbol', `list', `sexp',
:type '(float)
:group 'focus)
+(defvar focus-current-thing nil
+ "Overrides the choice of thing dictated by `focus-mode-to-thing' if set.")
+
(defvar focus-pre-overlay nil
"The overlay that dims the text prior to the current-point.")
@@ -82,13 +85,15 @@ The timer calls `focus-read-only-hide-cursor' after
`focus-read-only-blink-seconds' seconds.")
;; Use make-local-variable for backwards compatibility.
-(dolist (var '(focus-pre-overlay
+(dolist (var '(focus-current-thing
+ focus-pre-overlay
focus-post-overlay
focus-read-only-blink-timer))
(make-local-variable var))
;; Changing major-mode should not affect Focus mode.
-(dolist (var '(focus-pre-overlay
+(dolist (var '(focus-current-thing
+ focus-pre-overlay
focus-post-overlay
post-command-hook))
(put var 'permanent-local t))
@@ -101,9 +106,10 @@ The timer calls `focus-read-only-hide-cursor' after
(defun focus-get-thing ()
"Return the current thing, based on `focus-mode-to-thing'."
- (let* ((modes (mapcar 'car focus-mode-to-thing))
- (mode (focus-any 'derived-mode-p modes)))
- (if mode (cdr (assoc mode focus-mode-to-thing)) 'sentence)))
+ (or focus-current-thing
+ (let* ((modes (mapcar 'car focus-mode-to-thing))
+ (mode (focus-any 'derived-mode-p modes)))
+ (if mode (cdr (assoc mode focus-mode-to-thing)) 'sentence))))
(defun focus-bounds ()
"Return the current bounds, based on `focus-get-thing'."
@@ -168,6 +174,20 @@ deleted, and `focus-move-focus' is removed from
`post-command-hook'."
(goto-char (/ (+ (car bounds) (cdr bounds)) 2))
(recenter nil)))
+(defun focus-change-thing ()
+ "Adjust the narrowness of the focused section for the current buffer.
+
+The variable `focus-mode-to-thing' dictates the default thing
+according to major-mode. If `focus-current-thing' is set, this
+default is overwritten. This function simply helps set the
+`focus-current-thing'."
+ (interactive)
+ (let* ((candidates '(symbol list sexp defun
+ filename url email word
+ sentence whitespace line page))
+ (thing (completing-read "Thing: " candidates)))
+ (setq focus-current-thing (intern thing))))
+
(defun focus-next-thing (&optional n)
"Moves the point to the middle of the Nth next thing."
(interactive "p")
- [nongnu] elpa/focus 19b3c7b348 70/82: Just use a face for customizing the unfocused region, (continued)
- [nongnu] elpa/focus 19b3c7b348 70/82: Just use a face for customizing the unfocused region, ELPA Syncer, 2022/09/06
- [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 <=
- [nongnu] elpa/focus 90806dc7ea 18/82: Added custom variable for setting dimness, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 704db49988 82/82: Merge pull request #24 from phikal/master, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus c89d08f510 24/82: Applied purcell's recommendations, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 94ed8ab68b 36/82: Defined variables to help hide the cursor, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus e8c1eb5ce2 16/82: Added short commentary, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 75202c9445 58/82: Version bump, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 8028fc088f 04/82: Improved average color function, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus e9ab37b865 81/82: Improved user option types, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus aa5ea31118 65/82: Fixed package lint warnings., ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus a80b7b6eba 71/82: Add possibility of customizing the face of the focused region, ELPA Syncer, 2022/09/06