From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stephen Leake Newsgroups: gmane.emacs.devel Subject: Re: New ELPA package ada-lite Date: Wed, 17 Aug 2022 02:50:54 -0700 Message-ID: <86sflvfbb5.fsf@stephe-leake.org> References: <86y1vpfl1k.fsf@stephe-leake.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5939"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (windows-nt) Cc: emacs-devel To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Aug 17 11:59:39 2022 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 1oOFpr-0001Mi-GK for ged-emacs-devel@m.gmane-mx.org; Wed, 17 Aug 2022 11:59:39 +0200 Original-Received: from localhost ([::1]:46382 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oOFpq-0003f7-Gn for ged-emacs-devel@m.gmane-mx.org; Wed, 17 Aug 2022 05:59:38 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41656) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oOFif-0005c0-Lt for emacs-devel@gnu.org; Wed, 17 Aug 2022 05:52:13 -0400 Original-Received: from qproxy4-pub.mail.unifiedlayer.com ([66.147.248.250]:58436) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oOFic-0001NL-St for emacs-devel@gnu.org; Wed, 17 Aug 2022 05:52:13 -0400 Original-Received: from outbound-ss-761.bluehost.com (outbound-ss-761.bluehost.com [74.220.211.250]) by qproxy4.mail.unifiedlayer.com (Postfix) with ESMTP id 6DE01802B81D for ; Wed, 17 Aug 2022 09:51:55 +0000 (UTC) Original-Received: from cmgw13.mail.unifiedlayer.com (unknown [10.0.90.128]) by progateway8.mail.pro1.eigbox.com (Postfix) with ESMTP id 3F3EC100F151C for ; Wed, 17 Aug 2022 09:50:59 +0000 (UTC) Original-Received: from host2007.hostmonster.com ([67.20.76.71]) by cmsmtp with ESMTP id OFhSo4u1QG7RFOFhToQHsB; Wed, 17 Aug 2022 09:50:59 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=EscXEQQA c=1 sm=1 tr=0 ts=62fcba03 a=dWLzHQi6WpdymmZIwiVdBw==:117 a=Fln8i1WyhtedwaIJAdHvmw==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=biHskzXt2R4A:10:nop_rcvd_month_year a=vvvmwbhNdt4A:10:endurance_base64_authed_username_1 a=iRZporoAAAAA:8 a=HmPobh5AxH-IIUWziQMA:9 a=oG6b7N_NROKZNM4a1PkA:9 a=NOBgFS-JBQ2l-kSd6-zu:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=stephe-leake.org; s=default; h=Content-Type:MIME-Version:Message-ID:Date: References:In-Reply-To:Subject:Cc:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ZTzDumq/N+Nsbm0uoEpLPqiMs11Em8mRrLaanCu2u80=; b=kGXwYssoTUzWTOBKtNcZgnJqEo EiyrPkCvxhuqGFQeJ6bmZrYVhYn1GMmEh+8AQYTO77LNecho3V21RZeUrdtDrXKW6ftX8f5SQUkCO Uv2JpcV4QfwNlIAvAKUaPxToODdApyoBwMU+VdpnwBfLTmM29toFgBgWyCaMgy2Af0ONkS3NO+m4A c9rPc1Y5gF9NuYiHNjT+FmAIGs8BMlDnjUL8H9gEq6x4WwZow4usmR+uYVyRjy+TXq4Ej1NmiPS/1 tJfbYKTuPkYsXhBjWvOHbPO4V/uoQnYJxw7Zepf0TeS4M3IIfSINZ4BCDCErQUDSVzz+Go6EinTAC OjeXJWEQ==; Original-Received: from 135-180-197-170.fiber.dynamic.sonic.net ([135.180.197.170]:59237 helo=DESKTOP-G20DCG1) by host2007.hostmonster.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1oOFhS-00323S-Ey; Wed, 17 Aug 2022 03:50:58 -0600 In-Reply-To: (Stefan Monnier's message of "Mon, 15 Aug 2022 15:04:56 -0400") X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - host2007.hostmonster.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - stephe-leake.org X-BWhitelist: no X-Source-IP: 135.180.197.170 X-Source-L: No X-Exim-ID: 1oOFhS-00323S-Ey X-Source-Sender: 135-180-197-170.fiber.dynamic.sonic.net (DESKTOP-G20DCG1) [135.180.197.170]:59237 X-Source-Auth: stephen_leake@stephe-leake.org X-Email-Count: 2 X-Source-Cap: c3RlcGhlbGU7c3RlcGhlbGU7aG9zdDIwMDcuaG9zdG1vbnN0ZXIuY29t X-Local-Domain: yes Received-SPF: pass client-ip=66.147.248.250; envelope-from=stephen_leake@stephe-leake.org; helo=qproxy4-pub.mail.unifiedlayer.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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=no 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" Xref: news.gmane.io gmane.emacs.devel:293539 Archived-At: --=-=-= Content-Type: text/plain Stefan Monnier writes: >> I'd like to add a package ada-lite-mode to ELPA; code attached. The >> intent is to be a mode for Ada files that's easier to install than the >> current ELPA ada-mode. > > Sounds good, as long as the other ada-mode will be modified to (require > and) derive from (or extend) ada-lite. > > Currently, if both ada-mode and ada-lite packages are installed and > activated, their autoloads will fight for the top spot of > `auto-mode-alist`. Hmm. I was assuming only one would be activated. In my current testing, I have ada-mode disabled in package-load-list, so I have not run into this problem. I don't see how deriving ada-mode from ada-lite-mode helps here; there are still conflicting entries in auto-mode-alist. Almost all of ada-lite-mode is duplicated in ada-mode, so it would make sense to use ada-lite-mode in ada-mode. However, that means there would always be conficting entries in auto-mode-alist. If a user wants both modes available so they can decide on a file-by-file basis which one to use, they'll have to change auto-mode-alist before visiting a file, or change the mode after visiting, or something similar. Are there other modes in ELPA (or MELPA?) that support the same file extensions? There are several packages that mention "Python", for example (some in MELPA). I don't have all of ELPA checked out; perhaps you can do a grep-find for auto-mode-alist? > > A few more comments about the code: > Accepted unless commented on here; thanks for the detailed review. >> (defun ada-lite-syntax-propertize (start end) >> "For `syntax-propertize-function'. >> Assign `syntax-table' properties in region START .. END. >> In particular, character constants are set to have string syntax." >> ;; (info "(elisp)Syntax Properties") >> ;; >> ;; called from `syntax-propertize', inside save-excursion with-silent-modifications >> (let ((inhibit-read-only t) >> (inhibit-point-motion-hooks t)) > > `inhibit-point-motion-hooks` is t (and obsolete) since Emacs-25. Ah. I guess the byte-compiler doesn't report an obsolete warning here, because it's in a let? Can that be improved? > And `inhibit-read-only` should already be t since we're within > `with-silent-modifications`. Perhaps the doc string for syntax-propertize-function should state that it is called from within with-silent-modifications. And the doc string for with-silent-modifications should state that it sets inibit-read-only t. Patch attached. > >> (goto-char start) >> (save-match-data > > Why? I suspect this is left over from an earlier version of ada-mode. > I think > > (syntax-propertize-rules > ("[^[:alnum:])]\\('\\)[^'\n]\\('\\)" > (1 "\"'") > (2 "\"'") > ("[^[:alnum:])]\\('\\)'\\('\\)" > (1 "\"'") > (2 "\"'")) > > would do basically the same, but: > > - Is there a specific reason why you preferred to code it by hand > (speed maybe?) I was unaware of syntax-propertize-rules. > > - The second char in "\"'" is unused (it's only used for open/close > parentheses-like thingies). I guess "strings" are defined to always have the same start and end delimiters. > You could merge the two into: > > (syntax-propertize-rules > ("[^[:alnum:])]\\('\\)\\(?:'\\|[^'\n]\\)\\('\\)" > (1 "\"") > (2 "\"")) I'll test with this. >> (set (make-local-variable 'syntax-propertize-function) #'ada-lite-syntax-propertize) >> (syntax-ppss-flush-cache (point-min));; reparse with new function > > Why/when have you found this explicit flush to be necessary? When changing modes in a buffer, or just resetting the mode after editing ada-lite-syntax-propertize. You seem to be implying that syntax-ppss-flush-cache is already done by the "set major mode" code? >> (defun ada-lite-find-project (_dir) >> "If ada-lite-mode, return ada-lite project. >> For `project-find-functions'" >> (and (eq major-mode 'ada-lite-mode) > > I recommend (derived-mode-p 'ada-lite-mode) instead? That would be wrong for ada-mode if it derives from ada-lite-mode; ada-mode assumes a different kind of project. -- -- Stephe --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=misc.diff diff --git a/lisp/emacs-lisp/syntax.el b/lisp/emacs-lisp/syntax.el index e1be301583..6b239c36c8 100644 --- a/lisp/emacs-lisp/syntax.el +++ b/lisp/emacs-lisp/syntax.el @@ -57,10 +57,12 @@ syntax-propertize-function It is the work horse of `syntax-propertize', which is called by things like Font-Lock and indentation. -It is given two arguments, START and END: the start and end of the text to -which `syntax-table' might need to be applied. Major modes can use this to -override the buffer's syntax table for special syntactic constructs that -cannot be handled just by the buffer's syntax-table. +It is given two arguments, START and END: the start and end of +the text to which `syntax-table' might need to be applied. It is +called from within `with-silent-modifications'. Major modes can +use this to override the buffer's syntax table for special +syntactic constructs that cannot be handled just by the buffer's +syntax-table. The specified function may call `syntax-ppss' on any position before END, but if it calls `syntax-ppss' on some diff --git a/lisp/subr.el b/lisp/subr.el index ca4d52535a..2b44a0316a 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -4608,7 +4608,8 @@ with-silent-modifications than cosmetic ones, undo data may become corrupted. This macro will run BODY normally, but doesn't count its buffer -modifications as being buffer modifications. This affects things +modifications as being buffer modifications. `inhibit-read-only' +and 'inhibit-modification-hooks' are both t. This affects things like `buffer-modified-p', checking whether the file is locked by someone else, running buffer modification hooks, and other things of that nature." --=-=-=--