* bug#55980: 29.0.50; [PATCH] whitespace.el: New whitespace style `lines-char'
@ 2022-06-14 19:08 miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-06-15 12:24 ` Lars Ingebrigtsen
0 siblings, 1 reply; 2+ messages in thread
From: miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-06-14 19:08 UTC (permalink / raw)
To: 55980
[-- Attachment #1.1: Type: text/plain, Size: 157 bytes --]
Please see the attached patch which adds a new whitespace style to
highlight only the first character over the whitespace-line-column
limit.
Best regards.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-whitespace.el-New-whitespace-style-lines-char.patch --]
[-- Type: text/x-patch, Size: 7413 bytes --]
From d1c341e46206e7ce1615105cf6a0e70aebbc72e4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miha=20Rihtar=C5=A1i=C4=8D?= <miha@kamnitnik.top>
Date: Tue, 14 Jun 2022 21:02:22 +0200
Subject: [PATCH] whitespace.el: New whitespace style `lines-char'
* lisp/whitespace.el (whitespace-style):
(whitespace-style-value-list):
(whitespace-toggle-option-alist):
(global-whitespace-toggle-options):
(whitespace-help-text):
(whitespace-interactive-char):
(whitespace-style-face-p):
(whitespace-color-on):
(whitespace-lines-regexp): New whitespace style `lines-char', which
highlights only the first character over the whitespace-line-column
limit.
---
lisp/whitespace.el | 41 +++++++++++++++++++++++++++++++++--------
1 file changed, 33 insertions(+), 8 deletions(-)
diff --git a/lisp/whitespace.el b/lisp/whitespace.el
index 610d670ac9..a974336ace 100644
--- a/lisp/whitespace.el
+++ b/lisp/whitespace.el
@@ -295,8 +295,8 @@ whitespace-style
`whitespace-line-column' are highlighted via
faces.
Whole line is highlighted.
- It has precedence over `lines-tail' (see
- below).
+ It has precedence over `lines-tail' and
+ `lines-char' (see below).
It has effect only if `face' (see above)
is present in `whitespace-style'.
@@ -310,6 +310,17 @@ whitespace-style
and if `face' (see above) is present in
`whitespace-style'.
+ lines-char lines which have columns beyond
+ `whitespace-line-column' are highlighted via
+ faces.
+ But only the first character which goes
+ beyond `whitespace-line-column' column.
+ It has effect only if `lines' or
+ `lines-tail' (see above)
+ is not present in `whitespace-style'
+ and if `face' (see above) is present in
+ `whitespace-style'.
+
newline NEWLINEs are visualized via faces.
It has effect only if `face' (see above)
is present in `whitespace-style'.
@@ -431,6 +442,7 @@ whitespace-style
(const :tag "(Face) SPACEs and HARD SPACEs" spaces)
(const :tag "(Face) Lines" lines)
(const :tag "(Face) Lines, only overlong part" lines-tail)
+ (const :tag "(Face) Lines, only first character" lines-char)
(const :tag "(Face) NEWLINEs" newline)
(const :tag "(Face) Missing newlines at EOB"
missing-newline-at-eof)
@@ -772,7 +784,8 @@ whitespace-line-column
It must be an integer or nil. If nil, the `fill-column' variable value is
used.
-Used when `whitespace-style' includes `lines' or `lines-tail'."
+Used when `whitespace-style' includes `lines', `lines-tail' or
+`lines-char'."
:type '(choice :tag "Line Length Limit"
(integer :tag "Line Length")
(const :tag "Use fill-column" nil))
@@ -1058,6 +1071,7 @@ whitespace-style-value-list
trailing
lines
lines-tail
+ lines-char
newline
empty
indentation
@@ -1085,6 +1099,7 @@ whitespace-toggle-option-alist
(?r . trailing)
(?l . lines)
(?L . lines-tail)
+ (?\C-l . lines-char)
(?n . newline)
(?e . empty)
(?\C-i . indentation)
@@ -1244,6 +1259,7 @@ global-whitespace-toggle-options
r toggle trailing blanks visualization
l toggle \"long lines\" visualization
L toggle \"long lines\" tail visualization
+ C-l toggle \"long lines\" one character visualization
n toggle NEWLINE visualization
e toggle empty line at bob and/or eob visualization
C-i toggle indentation SPACEs visualization (via `indent-tabs-mode')
@@ -1274,6 +1290,7 @@ global-whitespace-toggle-options
trailing toggle trailing blanks visualization
lines toggle \"long lines\" visualization
lines-tail toggle \"long lines\" tail visualization
+ lines-char toggle \"long lines\" one character visualization
newline toggle NEWLINE visualization
empty toggle empty line at bob and/or eob visualization
indentation toggle indentation SPACEs visualization
@@ -1770,6 +1787,7 @@ whitespace-help-text
[] r - toggle trailing blanks visualization
[] l - toggle \"long lines\" visualization
[] L - toggle \"long lines\" tail visualization
+ [] C-l - toggle \"long lines\" one character visualization
[] n - toggle NEWLINE visualization
[] e - toggle empty line at bob and/or eob visualization
[] C-i - toggle indentation SPACEs visualization (via `indent-tabs-mode')
@@ -1892,6 +1910,7 @@ whitespace-interactive-char
r toggle trailing blanks visualization
l toggle \"long lines\" visualization
L toggle \"long lines\" tail visualization
+ C-l toggle \"long lines\" one character visualization
n toggle NEWLINE visualization
e toggle empty line at bob and/or eob visualization
C-i toggle indentation SPACEs visualization (via `indent-tabs-mode')
@@ -2020,6 +2039,7 @@ whitespace-style-face-p
(memq 'trailing whitespace-active-style)
(memq 'lines whitespace-active-style)
(memq 'lines-tail whitespace-active-style)
+ (memq 'lines-char whitespace-active-style)
(memq 'newline whitespace-active-style)
(memq 'empty whitespace-active-style)
(memq 'indentation whitespace-active-style)
@@ -2066,12 +2086,17 @@ whitespace-color-on
;; Show trailing blanks.
`((,#'whitespace-trailing-regexp 1 whitespace-trailing t)))
,@(when (or (memq 'lines whitespace-active-style)
- (memq 'lines-tail whitespace-active-style))
+ (memq 'lines-tail whitespace-active-style)
+ (memq 'lines-char whitespace-active-style))
;; Show "long" lines.
`((,#'whitespace-lines-regexp
- ,(if (memq 'lines whitespace-active-style)
- 0 ; whole line
- 2) ; line tail
+ ,(cond
+ ;; whole line
+ ((memq 'lines whitespace-active-style) 0)
+ ;; line tail
+ ((memq 'lines-tail whitespace-active-style) 2)
+ ;; first overflowing character
+ ((memq 'lines-char whitespace-active-style) 3))
whitespace-line prepend)))
,@(when (or (memq 'space-before-tab whitespace-active-style)
(memq 'space-before-tab::tab whitespace-active-style)
@@ -2182,7 +2207,7 @@ whitespace-lines-regexp
(re-search-forward
(let ((line-column (or whitespace-line-column fill-column)))
(format
- "^\\([^\t\n]\\{%s\\}\\|[^\t\n]\\{0,%s\\}\t\\)\\{%d\\}%s\\(.+\\)$"
+ "^\\([^\t\n]\\{%s\\}\\|[^\t\n]\\{0,%s\\}\t\\)\\{%d\\}%s\\(?2:\\(?3:.\\).*\\)$"
tab-width
(1- tab-width)
(/ line-column tab-width)
--
2.36.0
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]
^ permalink raw reply related [flat|nested] 2+ messages in thread
* bug#55980: 29.0.50; [PATCH] whitespace.el: New whitespace style `lines-char'
2022-06-14 19:08 bug#55980: 29.0.50; [PATCH] whitespace.el: New whitespace style `lines-char' miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-06-15 12:24 ` Lars Ingebrigtsen
0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2022-06-15 12:24 UTC (permalink / raw)
To: miha; +Cc: 55980
miha@kamnitnik.top writes:
> Please see the attached patch which adds a new whitespace style to
> highlight only the first character over the whitespace-line-column
> limit.
Thanks; pushed to Emacs 29 (with a minor rewording of one of the doc
strings).
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-06-15 12:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-14 19:08 bug#55980: 29.0.50; [PATCH] whitespace.el: New whitespace style `lines-char' miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-06-15 12:24 ` Lars Ingebrigtsen
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.