From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: master 6458e16: New mode outline-cycle-minor-mode with Orgmode-like TAB cycling on headings Date: Thu, 04 Mar 2021 20:12:42 +0200 Organization: LINKOV.NET Message-ID: <87o8fy7os5.fsf@mail.linkov.net> References: <20210303191236.24697.93201@vcs0.savannah.gnu.org> <20210303191237.2B2D720E1B@vcs0.savannah.gnu.org> <87zgzkug5d.fsf@mail.linkov.net> <87a6rj5jdl.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21205"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Mar 04 19:47:07 2021 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 1lHt07-0005PR-CU for ged-emacs-devel@m.gmane-mx.org; Thu, 04 Mar 2021 19:47:07 +0100 Original-Received: from localhost ([::1]:54478 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lHt06-00045r-7L for ged-emacs-devel@m.gmane-mx.org; Thu, 04 Mar 2021 13:47:06 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37816) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lHsxj-0002g5-UF for emacs-devel@gnu.org; Thu, 04 Mar 2021 13:44:39 -0500 Original-Received: from relay10.mail.gandi.net ([217.70.178.230]:59795) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lHsxh-0007Yj-VA for emacs-devel@gnu.org; Thu, 04 Mar 2021 13:44:39 -0500 Original-Received: from mail.gandi.net (m91-129-96-116.cust.tele2.ee [91.129.96.116]) (Authenticated sender: juri@linkov.net) by relay10.mail.gandi.net (Postfix) with ESMTPSA id CD0AB240008; Thu, 4 Mar 2021 18:44:33 +0000 (UTC) In-Reply-To: (Stefan Monnier's message of "Thu, 04 Mar 2021 08:20:08 -0500") Received-SPF: pass client-ip=217.70.178.230; envelope-from=juri@linkov.net; helo=relay10.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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:265978 Archived-At: > [ As for how to resolve it (in terms of behavior rather than in terms > of code), I think the cycling should only kick after trying > indentation and the indentation function did not change the buffer. > This is the kind of refinement in behavior which can't be obtained > just by key bindings but is (barely) obtainable via `add-function`. ] This fallback-on-no-op logic works for indentation, but not for e.g. diff-hunk-next (works only at the last hunk where TAB is no-op). Another idea is to put the cycling keymap only at the beginning of the outline heading line. Then at the beginning of the line TAB will cycle, while on the rest of the line TAB will fall back to the default binding to indent/navigate etc. >>>> 3. (add-hook 'emacs-lisp-mode-hook 'outline-cycle-minor-mode) >>>> without outline highlighting to not overwrite major mode faces >>> In which way did the highlighting get in the way? >> Actually, I discovered only now that outline faces with >> outline-minor-mode-highlight don't override major mode faces. > > So at least it currently doesn't get in the way ;-) > More seriously: it's because you've put `append` in the LAXMATCH part > rather than the OVERRIDE part of the font-lock-keywords rule. Ah, this explains everything. Now I tried to put it in the OVERRIDE part, and the result is angry fruit salad. >>> FWIW, I think the only really good way to solve this problem is to >>> replace `indent-for-tab-command` with a new command (call it >>> `tab-dwim`?) which can be more finely configured by major and minor >>> modes. E.g. by making it call `tab-dwim-function` on which modes can >>> `add-function` at will (and at various depths so they can control >>> whether it should take precedence or not over the "TAB causes >>> indentation" or "TAB causes completion", ...). >> >> The problem is that too many commands bound to TAB need to adapt >> this special handling: indent-for-tab-command, diff-hunk-next, >> compilation-next-error, forward-button, etc. etc. > > And I'm saying we should reduce this to a single command (`tab-dwim`) > and then instead of binding TAB modes should `add-function` to > `tab-dwim-function`. Adding font-lock faces on heading lines was necessary anyway, so currently it was easier to add a local cycling keymap to the same lines as well. But binding TAB globally to a general tab-dwim command, and allowing modes to set a buffer-local tab-dwim-function could work as well.