From: Elijah G <eg642616@gmail.com>
To: Philip Kaludercic <philipk@posteo.net>
Cc: emacs-devel@gnu.org
Subject: Re: [PATCH] Flymake Support Indicator Errors in Margin
Date: Tue, 12 Mar 2024 11:22:04 -0600 [thread overview]
Message-ID: <CACnP4NJmmuzno0BV-TgBisj2oQEcV8ZuEJKiv_TKerQ4UchHnQ@mail.gmail.com> (raw)
In-Reply-To: <87r0gfajlh.fsf@posteo.net>
[-- Attachment #1.1: Type: text/plain, Size: 10344 bytes --]
Thank you, I've fixed my patch.
Also I merged every flymake *-bitmap variable
into a single user option.
Also sorry for duplicating my reponses, I'm new in the mailing list.
On Tue, Mar 12, 2024 at 3:24 AM Philip Kaludercic <philipk@posteo.net>
wrote:
> Elijah G <eg642616@gmail.com> writes:
>
> > Hello developers,
> > this is my first time contributing to emacs,
> > i made support for displaying errors in margin for flymake like flycheck
> > does,
> > This allows indicating errors in both text and graphical mode.
> >
> > I've sent my copyright assignment request.
> >
> > Since this is my first time contributing i would like to hear your
> > suggestions and thoughts
> >
> > Thanks.
> > From 0d4539c6b8483eb13cfcdde3d73c71e430fdb30b Mon Sep 17 00:00:00 2001
> > From: Elias G <eg642616@gmail.com>
> > Date: Mon, 11 Mar 2024 13:35:06 -0600
> > Subject: [PATCH] Flymake Support Indicator Errors in Margin
> >
> > ---
> > etc/NEWS | 11 ++++
> > lisp/progmodes/flymake.el | 117 +++++++++++++++++++++++++++++++++-----
> > 2 files changed, 114 insertions(+), 14 deletions(-)
> >
> > diff --git a/etc/NEWS b/etc/NEWS
> > index 19cd170e5c7..83cf1ba9962 100644
> > --- a/etc/NEWS
> > +++ b/etc/NEWS
> > @@ -1121,6 +1121,17 @@ in a clean environment.
> >
> > ** Flymake
> >
> > ++++
> > +*** New user option 'flymake-indicator-type'
> > +Indicate which indicator type to use for display errors.
> > +
> > +The value can be nil (dont indicate errors but just highlight them),
> ^
> don't
>
> > +fringes (use fringes) or margins (use margins).
>
> But I am not sure if you really need to document this in NEWS. In fact,
> it might be possible to merge this and the next point:
>
> > +
> > ++++
> > +*** Support Display Errors Indicator in margin
> > +This allow indicate errors in both graphical and text display.
> > +
> > +++
> > *** New user option 'flymake-show-diagnostics-at-end-of-line'.
> > When non-nil, Flymake shows summarized descriptions of diagnostics at
> > diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
> > index db00cc59c0e..835f2057109 100644
> > --- a/lisp/progmodes/flymake.el
> > +++ b/lisp/progmodes/flymake.el
> > @@ -180,6 +180,73 @@ See `flymake-error-bitmap' and
> `flymake-warning-bitmap'."
> > (const right-fringe)
> > (const :tag "No fringe indicators" nil)))
> >
> > +(defcustom flymake-indicator-type 'fringes
> > + "Indicate which indicator type to use for display errors.
> > +
> > +The value can be nil (dont indicate errors but just highlight them),
> > +fringes (use fringes) or margins (use margins)
> > +
> > +Difference between fringes and margin is that fringes support diplaying
> > +bitmaps on graphical displays and margins display text in a blank area
> > +of buffer that works in both graphical and text displays.
> > +
> > +See Info node `Fringes' and Info node `(elisp)Display Margins'."
> > + :version "30.1"
> > + :type '(choice (const :tag "Use Fringes" fringes)
> > + (const :tag "Use Margins "margins)
> > + (const :tag "No indicators" nil)))
>
> There are tabs here.
>
> > +
> > +(defcustom flymake-error-margin-string '("‼" compilation-error)
> > + "String used in the margn for indicating errors.
> > +The value may also be a list of two elements where the second
> > +element specifies the face for the string.
> > +See also `flymake-warning-margin-string'.
> > +
> > +The option `flymake-margin-indicator-position' controls how and where
> > +this is used."
> > + :version "30.1"
> > + :type '(choice (string :tag "String")
> > + (list :tag "String and face"
> > + (string :tag "String")
> > + (face :tag "Face"))))
> > +
> > +(defcustom flymake-warning-margin-string '("!" compilation-warning)
> > + "String used in the margin for indicating warnings.
> > +The value may also be a list of two elements where the second
> > +element specifies the face for the string.
> > +See also `flymake-error-margin-string'.
> > +
> > +The option `flymake-margin-indicator-position' controls how and where
> > +this is used."
> > + :version "30.1"
> > + :type '(choice (string :tag "String")
> > + (list :tag "String and face"
> > + (string :tag "String")
> > + (face :tag "Face"))))
> > +
> > +(defcustom flymake-note-margin-string '("!" compilation-info)
> > + "String used in the margin for indicating info notes.
> > +The value may also be a list of two elements where the second
> > +element specifies the face for the string.
> > +See also `flymake-error-margin-string'.
> > +
> > +The option `flymake-margin-indicator-position' controls how and where
> > +this is used."
> > + :version "30.1"
> > + :type '(choice (string :tag "String")
> > + (list :tag "String and face"
> > + (string :tag "String")
> > + (face :tag "Face"))))
>
> Should or could these be merged into a single user option, that would
> then have the form
>
> '((error "‼" compilation-error)
> (note "!" compilation-warning)
> (info "!" compilation-info))
>
> > +
> > +(defcustom flymake-margin-indicator-position 'left-margin
> > + "The position to put Flymake margin indicator.
> > +The value can be nil (do not use indicators), `left-margin' or
> `right-margin'.
> > +See `flymake-error-margin-string' and `flymake-warning-margin-string'."
> > + :version "30.1"
> > + :type '(choice (const left-margin)
> > + (const right-margin)
> > + (const :tag "No margin indicators" nil)))
> > +
> > (make-obsolete-variable 'flymake-start-syntax-check-on-newline
> > "can check on newline in post-self-insert-hook"
> > "27.1")
> > @@ -630,6 +697,7 @@ Node `(Flymake)Flymake error types'"
> >
> > (put 'flymake-error 'face 'flymake-error)
> > (put 'flymake-error 'flymake-bitmap 'flymake-error-bitmap)
> > +(put 'flymake-error 'flymake-margin-string 'flymake-error-margin-string)
> > (put 'flymake-error 'severity (warning-numeric-level :error))
> > (put 'flymake-error 'mode-line-face 'flymake-error-echo)
> > (put 'flymake-error 'echo-face 'flymake-error-echo)
> > @@ -638,6 +706,7 @@ Node `(Flymake)Flymake error types'"
> >
> > (put 'flymake-warning 'face 'flymake-warning)
> > (put 'flymake-warning 'flymake-bitmap 'flymake-warning-bitmap)
> > +(put 'flymake-warning 'flymake-margin-string
> 'flymake-warning-margin-string)
> > (put 'flymake-warning 'severity (warning-numeric-level :warning))
> > (put 'flymake-warning 'mode-line-face 'flymake-warning-echo)
> > (put 'flymake-warning 'echo-face 'flymake-warning-echo)
> > @@ -646,6 +715,7 @@ Node `(Flymake)Flymake error types'"
> >
> > (put 'flymake-note 'face 'flymake-note)
> > (put 'flymake-note 'flymake-bitmap 'flymake-note-bitmap)
> > +(put 'flymake-note 'flymake-margin-string 'flymake-note-margin-string)
> > (put 'flymake-note 'severity (warning-numeric-level :debug))
> > (put 'flymake-note 'mode-line-face 'flymake-note-echo)
> > (put 'flymake-note 'echo-face 'flymake-note-echo)
> > @@ -682,19 +752,34 @@ associated `flymake-category' return DEFAULT."
> > (flymake--lookup-type-property type 'severity
> > (warning-numeric-level :error)))
> >
> > -(defun flymake--fringe-overlay-spec (bitmap &optional recursed)
> > - (if (and (symbolp bitmap)
> > - (boundp bitmap)
> > - (not recursed))
> > - (flymake--fringe-overlay-spec
> > - (symbol-value bitmap) t)
> > - (and flymake-fringe-indicator-position
> > - bitmap
> > - (propertize "!" 'display
> > - (cons flymake-fringe-indicator-position
> > - (if (listp bitmap)
> > - bitmap
> > - (list bitmap)))))))
> > +(defun flymake--fringe-overlay-spec (indicator)
> > + "Return INDICATOR-TYPE as propertized string to use in error
> indicators"
> > + (let* ((value (if (symbolp indicator)
> > + (symbol-value indicator)
> > + indicator))
> > + (indicator-car (if (listp value)
> > + (car value)
> > + value))
> > + (indicator-cdr (if (listp value)
> > + (cdr value))))
> > + (cond
> > + ((symbolp indicator-car)
> > + (propertize "!" 'display
> > + (cons flymake-fringe-indicator-position
> > + (if (listp value)
> > + value
> > + (list value)))))
> > + ((stringp indicator-car)
> > + (propertize "!"
> > + 'display
> > + `((margin ,flymake-margin-indicator-position)
> > + ,(propertize
> > + indicator-car
> > + 'face
> > + `(:inherit (,indicator-cdr
> > + default)
> > + )))))
>
> You should fold these parentheses back onto the previous line.
>
> > + (t nil))))
>
> This is not needed, as cond will default to nil if no case matched.
>
> >
> > (defun flymake--equal-diagnostic-p (a b)
> > "Tell if A and B are equivalent `flymake--diag' objects."
> > @@ -843,7 +928,11 @@ Return nil or the overlay created."
> > (flymake--fringe-overlay-spec
> > (flymake--lookup-type-property
> > type
> > - 'flymake-bitmap
> > + (cond ((eq flymake-indicator-type 'fringes)
> > + 'flymake-bitmap)
> > + ((eq flymake-indicator-type 'margins)
> > + 'flymake-margin-string)
> > + (t nil))
> > (alist-get 'bitmap (alist-get type ; backward compat
> >
> flymake-diagnostic-types-alist)))))
> > ;; (default-maybe 'after-string
>
> --
> Philip Kaludercic on peregrine
>
[-- Attachment #1.2: Type: text/html, Size: 13491 bytes --]
[-- Attachment #2: 0001-Flymake-Support-Indicator-Errors-in-Margin.patch --]
[-- Type: application/octet-stream, Size: 9482 bytes --]
From 4604566317ec4251231eeb06b331aada86e78ee7 Mon Sep 17 00:00:00 2001
From: Elias G <eg642616@gmail.com>
Date: Mon, 11 Mar 2024 13:35:06 -0600
Subject: [PATCH] Flymake Support Indicator Errors in Margin
---
lisp/progmodes/flymake.el | 144 ++++++++++++++++++++++++--------------
1 file changed, 90 insertions(+), 54 deletions(-)
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index db00cc59c0e..a812a2edc7b 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -128,46 +128,21 @@
:link '(custom-manual "(flymake) Top")
:group 'tools)
-(defcustom flymake-error-bitmap '(flymake-double-exclamation-mark
- compilation-error)
- "Bitmap (a symbol) used in the fringe for indicating errors.
-The value may also be a list of two elements where the second
-element specifies the face for the bitmap. For possible bitmap
-symbols, see `fringe-bitmaps'. See also `flymake-warning-bitmap'.
+(defcustom flymake-fringe-indicators-bitmap
+ '((error flymake-double-exclamation-mark compilation-error)
+ (warning exclamation-mark compilation-warning)
+ (note exclamation-mark compilation-info))
+ "Bitmap (a symbol) used for fringes indicators.
+The value of each list may be a list of 3 elements where specifies the
+error type, its bitmap to use and its face,
+or a list of 2 elements specifying only the error type and its bitmap.
The option `flymake-fringe-indicator-position' controls how and where
this is used."
- :version "24.3"
- :type '(choice (symbol :tag "Bitmap")
- (list :tag "Bitmap and face"
- (symbol :tag "Bitmap")
- (face :tag "Face"))))
-
-(defcustom flymake-warning-bitmap '(exclamation-mark compilation-warning)
- "Bitmap (a symbol) used in the fringe for indicating warnings.
-The value may also be a list of two elements where the second
-element specifies the face for the bitmap. For possible bitmap
-symbols, see `fringe-bitmaps'. See also `flymake-error-bitmap'.
-
-The option `flymake-fringe-indicator-position' controls how and where
-this is used."
- :version "24.3"
- :type '(choice (symbol :tag "Bitmap")
- (list :tag "Bitmap and face"
- (symbol :tag "Bitmap")
- (face :tag "Face"))))
-
-(defcustom flymake-note-bitmap '(exclamation-mark compilation-info)
- "Bitmap (a symbol) used in the fringe for indicating info notes.
-The value may also be a list of two elements where the second
-element specifies the face for the bitmap. For possible bitmap
-symbols, see `fringe-bitmaps'. See also `flymake-error-bitmap'.
-
-The option `flymake-fringe-indicator-position' controls how and where
-this is used."
- :version "26.1"
- :type '(choice (symbol :tag "Bitmap")
- (list :tag "Bitmap and face"
+ :version "30.1"
+ :type '(repeat :tag "Error types lists"
+ (list :tag "String and face for error types"
+ (symbol :tag "Error type")
(symbol :tag "Bitmap")
(face :tag "Face"))))
@@ -180,6 +155,48 @@ See `flymake-error-bitmap' and `flymake-warning-bitmap'."
(const right-fringe)
(const :tag "No fringe indicators" nil)))
+(defcustom flymake-indicator-type 'fringes
+ "Indicate which indicator type to use for display errors.
+
+The value can be nil (dont indicate errors but just highlight them),
+fringes (use fringes) or margins (use margins)
+
+Difference between fringes and margin is that fringes support diplaying
+bitmaps on graphical displays and margins display text in a blank area
+of buffer that works in both graphical and text displays.
+
+See Info node `Fringes' and Info node `(elisp)Display Margins'."
+ :version "30.1"
+ :type '(choice (const :tag "Use Fringes" fringes)
+ (const :tag "Use Margins "margins)
+ (const :tag "No indicators" nil)))
+
+(defcustom flymake-margin-indicators-string '((error "‼" compilation-error)
+ (warning "!" compilation-warning)
+ (note "!" compilation-info))
+ "Strings used for margins indicators.
+The value of each list may be a list of 3 elements where specifies the
+error type, its string to use and its face,
+or a list of 2 elements specifying only the error type and its string.
+
+The option `flymake-margin-indicator-position' controls how and where
+this is used."
+ :version "30.1"
+ :type '(repeat :tag "Error types lists"
+ (list :tag "String and face for error types"
+ (symbol :tag "Error type")
+ (string :tag "String")
+ (face :tag "Face"))))
+
+(defcustom flymake-margin-indicator-position 'left-margin
+ "The position to put Flymake margin indicator.
+The value can be nil (do not use indicators), `left-margin' or `right-margin'.
+See `flymake-error-margin-string' and `flymake-warning-margin-string'."
+ :version "30.1"
+ :type '(choice (const left-margin)
+ (const right-margin)
+ (const :tag "No margin indicators" nil)))
+
(make-obsolete-variable 'flymake-start-syntax-check-on-newline
"can check on newline in post-self-insert-hook"
"27.1")
@@ -629,7 +646,8 @@ Node `(Flymake)Flymake error types'"
"27.1")
(put 'flymake-error 'face 'flymake-error)
-(put 'flymake-error 'flymake-bitmap 'flymake-error-bitmap)
+(put 'flymake-error 'flymake-bitmap (alist-get 'error flymake-fringe-indicators-bitmap))
+(put 'flymake-error 'flymake-margin-string (alist-get 'error flymake-margin-indicators-string))
(put 'flymake-error 'severity (warning-numeric-level :error))
(put 'flymake-error 'mode-line-face 'flymake-error-echo)
(put 'flymake-error 'echo-face 'flymake-error-echo)
@@ -637,7 +655,8 @@ Node `(Flymake)Flymake error types'"
(put 'flymake-error 'flymake-type-name "error")
(put 'flymake-warning 'face 'flymake-warning)
-(put 'flymake-warning 'flymake-bitmap 'flymake-warning-bitmap)
+(put 'flymake-warning 'flymake-bitmap (alist-get 'warning flymake-fringe-indicators-bitmap))
+(put 'flymake-warning 'flymake-margin-string (alist-get 'error flymake-margin-indicators-string))
(put 'flymake-warning 'severity (warning-numeric-level :warning))
(put 'flymake-warning 'mode-line-face 'flymake-warning-echo)
(put 'flymake-warning 'echo-face 'flymake-warning-echo)
@@ -645,7 +664,8 @@ Node `(Flymake)Flymake error types'"
(put 'flymake-warning 'flymake-type-name "warning")
(put 'flymake-note 'face 'flymake-note)
-(put 'flymake-note 'flymake-bitmap 'flymake-note-bitmap)
+(put 'flymake-note 'flymake-bitmap (alist-get 'note flymake-fringe-indicators-bitmap))
+(put 'flymake-note 'flymake-margin-string (alist-get 'error flymake-margin-indicators-string))
(put 'flymake-note 'severity (warning-numeric-level :debug))
(put 'flymake-note 'mode-line-face 'flymake-note-echo)
(put 'flymake-note 'echo-face 'flymake-note-echo)
@@ -682,19 +702,32 @@ associated `flymake-category' return DEFAULT."
(flymake--lookup-type-property type 'severity
(warning-numeric-level :error)))
-(defun flymake--fringe-overlay-spec (bitmap &optional recursed)
- (if (and (symbolp bitmap)
- (boundp bitmap)
- (not recursed))
- (flymake--fringe-overlay-spec
- (symbol-value bitmap) t)
- (and flymake-fringe-indicator-position
- bitmap
- (propertize "!" 'display
- (cons flymake-fringe-indicator-position
- (if (listp bitmap)
- bitmap
- (list bitmap)))))))
+(defun flymake--fringe-overlay-spec (indicator)
+ "Return INDICATOR as propertized string to use in error indicators."
+ (let* ((value (if (symbolp indicator)
+ (symbol-value indicator)
+ indicator))
+ (indicator-car (if (listp value)
+ (car value)
+ value))
+ (indicator-cdr (if (listp value)
+ (cdr value))))
+ (cond
+ ((symbolp indicator-car)
+ (propertize "!" 'display
+ (cons flymake-fringe-indicator-position
+ (if (listp value)
+ value
+ (list value)))))
+ ((stringp indicator-car)
+ (propertize "!"
+ 'display
+ `((margin ,flymake-margin-indicator-position)
+ ,(propertize
+ indicator-car
+ 'face
+ `(:inherit (,indicator-cdr
+ default)))))))))
(defun flymake--equal-diagnostic-p (a b)
"Tell if A and B are equivalent `flymake--diag' objects."
@@ -843,7 +876,10 @@ Return nil or the overlay created."
(flymake--fringe-overlay-spec
(flymake--lookup-type-property
type
- 'flymake-bitmap
+ (cond ((eq flymake-indicator-type 'fringes)
+ 'flymake-bitmap)
+ ((eq flymake-indicator-type 'margins)
+ 'flymake-margin-string))
(alist-get 'bitmap (alist-get type ; backward compat
flymake-diagnostic-types-alist)))))
;; (default-maybe 'after-string
--
2.44.0.windows.1
next prev parent reply other threads:[~2024-03-12 17:22 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-11 23:18 [PATCH] Flymake Support Indicator Errors in Margin Elijah G
2024-03-12 9:24 ` Philip Kaludercic
2024-03-12 17:22 ` Elijah G [this message]
2024-03-13 12:18 ` Eli Zaretskii
2024-03-14 1:50 ` Elijah G
2024-03-14 11:05 ` Eli Zaretskii
2024-03-14 11:28 ` João Távora
2024-03-14 15:35 ` Elijah G
2024-03-16 11:10 ` Eli Zaretskii
2024-03-17 16:44 ` bird
2024-03-17 17:01 ` Eli Zaretskii
2024-03-17 17:34 ` Elijah G
2024-03-17 18:43 ` bird
2024-03-17 19:21 ` Elijah G
2024-03-25 1:46 ` Elijah G
2024-03-27 0:13 ` sbaugh
2024-03-27 0:36 ` Elijah G
2024-03-27 21:29 ` Elijah G
2024-03-28 6:01 ` Eli Zaretskii
2024-03-28 17:34 ` Elijah G
2024-04-06 11:36 ` Eli Zaretskii
2024-03-28 7:30 ` Juri Linkov
2024-03-28 17:44 ` Elijah G
2024-04-06 11:35 ` Eli Zaretskii
2024-04-06 20:14 ` Elijah G
2024-04-07 5:47 ` Eli Zaretskii
2024-04-07 17:20 ` Elijah G
2024-04-18 9:10 ` Eli Zaretskii
2024-03-19 7:03 ` Augusto Stoffel
2024-03-17 17:49 ` Elijah G
2024-03-19 7:04 ` Augusto Stoffel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CACnP4NJmmuzno0BV-TgBisj2oQEcV8ZuEJKiv_TKerQ4UchHnQ@mail.gmail.com \
--to=eg642616@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=philipk@posteo.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).