From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Flymake Support Indicator Errors in Margin Date: Tue, 12 Mar 2024 09:24:26 +0000 Message-ID: <87r0gfajlh.fsf@posteo.net> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8384"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Elijah G Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Mar 12 10:25:38 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rjyOA-0001z3-K8 for ged-emacs-devel@m.gmane-mx.org; Tue, 12 Mar 2024 10:25:38 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjyNC-0002Xq-9m; Tue, 12 Mar 2024 05:24:38 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjyN9-0002Xh-CL for emacs-devel@gnu.org; Tue, 12 Mar 2024 05:24:35 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjyN6-0002wv-Qd for emacs-devel@gnu.org; Tue, 12 Mar 2024 05:24:35 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 1D54924002A for ; Tue, 12 Mar 2024 10:24:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1710235468; bh=omlN7C3XSs/6ZlKOnNI8dkXxL+amNqWpr9G4iJTeQLc=; h=From:To:Cc:Subject:OpenPGP:Date:Message-ID:MIME-Version: Content-Type:Content-Transfer-Encoding:From; b=dG5QF33mAbqK0eFAD+QfL4C6tNubSf25WCrNGTTqpo8+m3NZThV6u57ily4EVVW2Z oyDUyURbsDl8tYQueISwJzudJPOeSF/Z16qtNR0OFjHCqWrzl0sUzmbVZJ8Tthd1OW dcQCa/AggNGJB+hlyGJ5mQRapTu/QMgkeDgwlWmHQecE5KRnyDWyNc6lpsFdq9Ty/X M7g/jU8W3GShewNGr713cjkxDz7lHPWRQ3B6OSe0/YCbA/bN+TmwqjCvfgOmij6plG /JAJn9JMHq8MUC0McPclHqzvwoXkIjBLs936V9omjkySGrsrG1cFq0Ffbsv3cy3Iqh kYBmT57SbMvtg== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Tv7Wb44pTz6txP; Tue, 12 Mar 2024 10:24:27 +0100 (CET) In-Reply-To: (Elijah G.'s message of "Mon, 11 Mar 2024 17:18:39 -0600") OpenPGP: id=7126E1DE2F0CE35C770BED01F2C3CC513DB89F66; url="https://keys.openpgp.org/vks/v1/by-fingerprint/7126E1DE2F0CE35C770BED01F2C3CC513DB89F66"; preference=signencrypt Received-SPF: pass client-ip=185.67.36.65; envelope-from=philipk@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:317009 Archived-At: Elijah G 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 > 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. >=20=20 > ** Flymake >=20=20 > ++++ > +*** 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 =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20 > +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-bitm= ap'." > (const right-fringe) > (const :tag "No fringe indicators" nil))) >=20=20 > +(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 '("=E2=80=BC" 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 "=E2=80=BC" 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-ma= rgin'. > +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'" >=20=20 > (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'" >=20=20 > (put 'flymake-warning 'face 'flymake-warning) > (put 'flymake-warning 'flymake-bitmap 'flymake-warning-bitmap) > +(put 'flymake-warning 'flymake-margin-string 'flymake-warning-margin-str= ing) > (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'" >=20=20 > (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))) >=20=20 > -(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 indicator= s" > + (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. >=20=20 > (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 --=20 Philip Kaludercic on peregrine