unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#50679: 28.0.50; outline-minor-mode-cycle should be able to only cycle at the begining of a line
@ 2021-09-19 16:24 Philip Kaludercic
  2021-09-19 16:53 ` Juri Linkov
  0 siblings, 1 reply; 21+ messages in thread
From: Philip Kaludercic @ 2021-09-19 16:24 UTC (permalink / raw)
  To: 50679


I like the new outline-minor-mode-cycle option, but it becomes annoying
in combination with tab-always-indent set to 'complete, because outline
takes over, even if I don't expect it.

Replacing the (outline-on-heading-p) check with 

          (looking-at outline-regexp)

or

          (and (bolp) (looking-at outline-regexp))

improves the experience for me, but I am not sure if
this is a general improvement. Could it make sense to have this as a
configurable option, or check the value of tab-always-indent and DWIM?


In GNU Emacs 28.0.50 (build 12, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw scroll bars)
 of 2021-09-18 built on icterid
Repository revision: 2557c009bb1b7b9bc001aee5e6cd1c0054de83d6
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Debian GNU/Linux 11 (bullseye)

Configured using:
 'configure LDFLAGS=-flto 'CFLAGS=-O2 -march=native -mtune=native -pipe'
 --with-native-compilation PKG_CONFIG_PATH='

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NATIVE_COMP
NOTIFY INOTIFY PDUMPER PNG SECCOMP SOUND THREADS TIFF
TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM LUCID ZLIB

Important settings:
  value of $EMACSLOADPATH: 
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Outline

Minor modes in effect:
  shell-dirtrack-mode: t
  bug-reference-mode: t
  flyspell-mode: t
  display-time-mode: t
  winner-mode: t
  windmove-mode: t
  electric-pair-mode: t
  recentf-mode: t
  save-place-mode: t
  savehist-mode: t
  show-paren-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tab-bar-mode: t
  file-name-shadow-mode: t
  context-menu-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  temp-buffer-resize-mode: t
  buffer-read-only: t
  line-number-mode: t
  auto-fill-function: do-auto-fill
  indent-tabs-mode: t
  transient-mark-mode: t
  view-mode: t

Load-path shadows:
/home/philip/.config/emacs/elpa/transient-0.3.6/transient hides /home/philip/Code/src/emacs/lisp/transient
~/.config/emacs/site-lisp/autoload hides /home/philip/Code/src/emacs/lisp/emacs-lisp/autoload

Features:
(shadow slime-tests slime hyperspec mm-archive smiley gnus-cite
gnus-async gnus-bcklg qp gnus-ml disp-table mode-local ert-x ert ewoc
emacsbug repeat mhtml-mode css-mode smie eww url-queue mm-url js imenu
sgml-mode facemenu arc-mode archive-mode autorevert filenotify doc-view
image-mode exif mailalias bbdb-pgp sort bbdb-message mail-extr
autocrypt-message autocrypt-gnus autocrypt nndraft nnmh epa-file gnutls
network-stream nsm nnmaildir nnfolder bbdb-gnus bbdb-mua bbdb-com nnnil
gnus-agent gnus-srvr gnus-score score-mode nnvirtual gnus-msg gnus-art
mm-uu mml2015 mm-view mml-smime smime dig nntp gnus-cache gnus-sum shr
kinsoku svg dom gnus-group gnus-undo gnus-start gnus-dbus dbus xml
gnus-cloud nnimap nnmail mail-source utf7 netrc nnoo parse-time iso8601
gnus-spec gnus-int gnus-range message rmc puny rfc822 mml mml-sec epa
epg rfc6068 epg-config mm-decode mm-bodies mm-encode mailabbrev
gmm-utils mailheader gnus-win ffap crdt xdg completion vc-mtn vc-hg
vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs grep magit-utils crm dash
jka-compr apropos cl-print debug backtrace mule-util compat smerge-mode
add-log scroll-all follow etags fileloop generator view shell char-fold
eieio-opt speedbar ezimage dframe shortdoc org ob ob-tangle ob-ref
ob-lob ob-table ob-exp org-macro org-footnote org-src ob-comint
org-pcomplete pcomplete org-list org-faces org-entities org-version
ob-emacs-lisp ob-core ob-eval org-table ol org-keys org-compat advice
org-macs org-loaddefs format-spec allout cus-edit cus-start reposition
avy time-stamp flymake-cc pulse color vc-git diff-mode bug-reference
macrostep-c cmacexp macrostep pp cc-mode cc-fonts cc-guess cc-menus
cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs find-func xref
misearch multi-isearch help-at-pt vc-backup log-view pcvs-util diff
vc-fossil vc vc-dispatcher dired-aux paredit corfu checkdoc flymake-proc
flymake project thingatpt flyspell ispell noutline outline easy-mmode
comp comp-cstr warnings cl-extra gnus-dired dired-x dired dired-loaddefs
rx time bbdb derived bbdb-site timezone sendmail gnus nnheader gnus-util
rmail rmail-loaddefs time-date mail-utils hippie-exp winner windmove
elec-pair recentf tree-widget wid-edit saveplace savehist paren
modus-operandi-theme modus-themes pcase edmacro kmacro holidays
hol-loaddefs cal-menu calendar cal-loaddefs cus-load setup load compile
text-property-search comint ansi-color autoload lisp-mnt mail-parse
rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr tex-site
geiser-impl help-fns radix-tree help-mode geiser-custom geiser-base ring
slime-autoloads info package browse-url url url-proxy url-privacy
url-expand url-methods url-history url-cookie url-domsuf url-util
mailcap url-handlers url-parse auth-source cl-seq eieio eieio-core
cl-macs eieio-loaddefs password-cache json subr-x map url-vars seq
byte-opt gv bytecomp byte-compile cconv cl-loaddefs cl-lib iso-transl
tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type
elisp-mode mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd
fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow
isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax
font-core term/tty-colors frame minibuffer cl-generic cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese composite charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice button loaddefs faces cus-face macroexp files
window text-properties overlay sha1 md5 base64 format env code-pages
mule custom widget hashtable-print-readable backquote threads dbusbind
inotify dynamic-setting system-font-setting font-render-setting cairo
x-toolkit x multi-tty make-network-process native-compile emacs)

Memory information:
((conses 16 897653 621228)
 (symbols 48 42429 70)
 (strings 32 169188 70225)
 (string-bytes 1 5972522)
 (vectors 16 84010)
 (vector-slots 8 2108446 801160)
 (floats 8 648 1092)
 (intervals 56 28827 11991)
 (buffers 992 60))

-- 
	Philip K.





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#50679: 28.0.50; outline-minor-mode-cycle should be able to only cycle at the begining of a line
  2021-09-19 16:24 bug#50679: 28.0.50; outline-minor-mode-cycle should be able to only cycle at the begining of a line Philip Kaludercic
@ 2021-09-19 16:53 ` Juri Linkov
  2021-09-19 20:40   ` Philip Kaludercic
  0 siblings, 1 reply; 21+ messages in thread
From: Juri Linkov @ 2021-09-19 16:53 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: 50679

> I like the new outline-minor-mode-cycle option, but it becomes annoying
> in combination with tab-always-indent set to 'complete, because outline
> takes over, even if I don't expect it.

This is a known problem without a good solution.
It misbehaves even when tab-always-indent is set to 't'.

> Replacing the (outline-on-heading-p) check with 
>
>           (looking-at outline-regexp)
>
> or
>
>           (and (bolp) (looking-at outline-regexp))
>
> improves the experience for me, but I am not sure if
> this is a general improvement. Could it make sense to have this as a
> configurable option, or check the value of tab-always-indent and DWIM?

So you propose to cycle only at the beginning of the line?
But when tab-always-indent is set to 't', sometimes typing TAB
at the beginning of the line is expected to indent the line
instead of cycling outlines.





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#50679: 28.0.50; outline-minor-mode-cycle should be able to only cycle at the begining of a line
  2021-09-19 16:53 ` Juri Linkov
@ 2021-09-19 20:40   ` Philip Kaludercic
  2021-09-20  7:02     ` Juri Linkov
  0 siblings, 1 reply; 21+ messages in thread
From: Philip Kaludercic @ 2021-09-19 20:40 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 50679

Juri Linkov <juri@linkov.net> writes:

>> Replacing the (outline-on-heading-p) check with 
>>
>>           (looking-at outline-regexp)
>>
>> or
>>
>>           (and (bolp) (looking-at outline-regexp))
>>
>> improves the experience for me, but I am not sure if
>> this is a general improvement. Could it make sense to have this as a
>> configurable option, or check the value of tab-always-indent and DWIM?
>
> So you propose to cycle only at the beginning of the line?
> But when tab-always-indent is set to 't', sometimes typing TAB
> at the beginning of the line is expected to indent the line
> instead of cycling outlines.

I didn't necessarily propose anything, it might only be able to solve
this using a option like

     (defcustom outline-minor-mode-cycle-predicate ...)

as to allow for users to configure cycling as they see fit. Of course if
some consistent behaviour could be found that respects other options and
modes, then something automatic could also be used. 

-- 
	Philip Kaludercic





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#50679: 28.0.50; outline-minor-mode-cycle should be able to only cycle at the begining of a line
  2021-09-19 20:40   ` Philip Kaludercic
@ 2021-09-20  7:02     ` Juri Linkov
  2021-09-20 15:25       ` Juri Linkov
  0 siblings, 1 reply; 21+ messages in thread
From: Juri Linkov @ 2021-09-20  7:02 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: 50679

> I didn't necessarily propose anything, it might only be able to solve
> this using a option like
>
>      (defcustom outline-minor-mode-cycle-predicate ...)
>
> as to allow for users to configure cycling as they see fit. Of course if
> some consistent behaviour could be found that respects other options and
> modes, then something automatic could also be used.

Probably offloading the decision to the users with a customizable option
is all what we can do here, indeed.





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#50679: 28.0.50; outline-minor-mode-cycle should be able to only cycle at the begining of a line
  2021-09-20  7:02     ` Juri Linkov
@ 2021-09-20 15:25       ` Juri Linkov
  2021-09-20 15:35         ` Philip Kaludercic
  0 siblings, 1 reply; 21+ messages in thread
From: Juri Linkov @ 2021-09-20 15:25 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: 50679

>> I didn't necessarily propose anything, it might only be able to solve
>> this using a option like
>>
>>      (defcustom outline-minor-mode-cycle-predicate ...)
>>
>> as to allow for users to configure cycling as they see fit. Of course if
>> some consistent behaviour could be found that respects other options and
>> modes, then something automatic could also be used.
>
> Probably offloading the decision to the users with a customizable option
> is all what we can do here, indeed.

Maybe something like:

 (defvar outline-mode-cycle-map
   (let ((map (make-sparse-keymap)))
     (let ((tab-binding `(menu-item
                          "" outline-cycle
                          ;; Only takes effect if point is on a heading.
                          :filter ,(lambda (cmd)
-                                    (when (outline-on-heading-p) cmd)))))
+                                    (when (and (outline-on-heading-p)
+                                               (or (not (functionp outline-mode-cycle-filter))
+                                                   (funcall outline-mode-cycle-filter)))
+                                      cmd)))))
       (define-key map (kbd "TAB") tab-binding)
       (define-key map (kbd "<backtab>") #'outline-cycle-buffer))
     map)

Then you can customize it to 'bolp'.





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#50679: 28.0.50; outline-minor-mode-cycle should be able to only cycle at the begining of a line
  2021-09-20 15:25       ` Juri Linkov
@ 2021-09-20 15:35         ` Philip Kaludercic
  2021-09-20 18:36           ` Augusto Stoffel
                             ` (2 more replies)
  0 siblings, 3 replies; 21+ messages in thread
From: Philip Kaludercic @ 2021-09-20 15:35 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 50679

Juri Linkov <juri@linkov.net> writes:

>>> I didn't necessarily propose anything, it might only be able to solve
>>> this using a option like
>>>
>>>      (defcustom outline-minor-mode-cycle-predicate ...)
>>>
>>> as to allow for users to configure cycling as they see fit. Of course if
>>> some consistent behaviour could be found that respects other options and
>>> modes, then something automatic could also be used.
>>
>> Probably offloading the decision to the users with a customizable option
>> is all what we can do here, indeed.
>
> Maybe something like:
>
>  (defvar outline-mode-cycle-map
>    (let ((map (make-sparse-keymap)))
>      (let ((tab-binding `(menu-item
>                           "" outline-cycle
>                           ;; Only takes effect if point is on a heading.
>                           :filter ,(lambda (cmd)
> -                                    (when (outline-on-heading-p) cmd)))))
> +                                    (when (and (outline-on-heading-p)
> +                                               (or (not (functionp outline-mode-cycle-filter))
> +                                                   (funcall outline-mode-cycle-filter)))
> +                                      cmd)))))
>        (define-key map (kbd "TAB") tab-binding)
>        (define-key map (kbd "<backtab>") #'outline-cycle-buffer))
>      map)
>
> Then you can customize it to 'bolp'.

I just tried it out, and it looks good. The only thing I wonder is if
this should apply to both outline-minor-mode and outline-mode?

-- 
	Philip Kaludercic





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#50679: 28.0.50; outline-minor-mode-cycle should be able to only cycle at the begining of a line
  2021-09-20 15:35         ` Philip Kaludercic
@ 2021-09-20 18:36           ` Augusto Stoffel
  2021-09-21 11:27             ` Philip Kaludercic
                               ` (2 more replies)
  2021-09-21 17:53           ` Juri Linkov
  2021-09-23 16:17           ` Juri Linkov
  2 siblings, 3 replies; 21+ messages in thread
From: Augusto Stoffel @ 2021-09-20 18:36 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: 50679, Juri Linkov

On Mon, 20 Sep 2021 at 15:35, Philip Kaludercic <philipk@posteo.net> wrote:

> Juri Linkov <juri@linkov.net> writes:
>
>>>> I didn't necessarily propose anything, it might only be able to solve
>>>> this using a option like
>>>>
>>>>      (defcustom outline-minor-mode-cycle-predicate ...)
>>>>
>>>> as to allow for users to configure cycling as they see fit. Of course if
>>>> some consistent behaviour could be found that respects other options and
>>>> modes, then something automatic could also be used.
>>>
>>> Probably offloading the decision to the users with a customizable option
>>> is all what we can do here, indeed.
>>
>> Maybe something like:
>>
>>  (defvar outline-mode-cycle-map
>>    (let ((map (make-sparse-keymap)))
>>      (let ((tab-binding `(menu-item
>>                           "" outline-cycle
>>                           ;; Only takes effect if point is on a heading.
>>                           :filter ,(lambda (cmd)
>> -                                    (when (outline-on-heading-p) cmd)))))
>> +                                    (when (and (outline-on-heading-p)
>> +                                               (or (not (functionp outline-mode-cycle-filter))
>> +                                                   (funcall outline-mode-cycle-filter)))
>> +                                      cmd)))))
>>        (define-key map (kbd "TAB") tab-binding)
>>        (define-key map (kbd "<backtab>") #'outline-cycle-buffer))
>>      map)
>>
>> Then you can customize it to 'bolp'.
>
> I just tried it out, and it looks good. The only thing I wonder is if
> this should apply to both outline-minor-mode and outline-mode?

FWIW, I think it would be nice to provide a simple way to define other
“speed keys” in `outline-minor-mode [1], or even provide some
pre-configured ones [2].

Looking at the code, it seems that adding bindings to
`outline-mode-cycle-map` would achieve precisely that, but the name
of the keymap doesn't reflect that.

[1]: Cf. https://orgmode.org/manual/Speed-Keys.html

[2]: I personally use these speed keys in outline-minor-mode, which are
probably very similar to those from Org mode:

        "<tab>" 'outline-cycle
        "<backtab>" 'outline-cycle-buffer
        "f" 'outline-forward-same-level
        "b" 'outline-backward-same-level
        "n" 'outline-next-visible-heading
        "p" 'outline-previous-visible-heading
        "u" 'outline-up-heading
        "F" 'outline-move-subtree-down
        "B" 'outline-move-subtree-up
        "@" 'outline-mark-subtree





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#50679: 28.0.50; outline-minor-mode-cycle should be able to only cycle at the begining of a line
  2021-09-20 18:36           ` Augusto Stoffel
@ 2021-09-21 11:27             ` Philip Kaludercic
  2021-09-21 11:44               ` Augusto Stoffel
  2021-09-21 17:58             ` Juri Linkov
  2021-09-23 16:15             ` Juri Linkov
  2 siblings, 1 reply; 21+ messages in thread
From: Philip Kaludercic @ 2021-09-21 11:27 UTC (permalink / raw)
  To: Augusto Stoffel; +Cc: 50679, Juri Linkov

Augusto Stoffel <arstoffel@gmail.com> writes:

> On Mon, 20 Sep 2021 at 15:35, Philip Kaludercic <philipk@posteo.net> wrote:
>
>> Juri Linkov <juri@linkov.net> writes:
>>
>>>>> I didn't necessarily propose anything, it might only be able to solve
>>>>> this using a option like
>>>>>
>>>>>      (defcustom outline-minor-mode-cycle-predicate ...)
>>>>>
>>>>> as to allow for users to configure cycling as they see fit. Of course if
>>>>> some consistent behaviour could be found that respects other options and
>>>>> modes, then something automatic could also be used.
>>>>
>>>> Probably offloading the decision to the users with a customizable option
>>>> is all what we can do here, indeed.
>>>
>>> Maybe something like:
>>>
>>>  (defvar outline-mode-cycle-map
>>>    (let ((map (make-sparse-keymap)))
>>>      (let ((tab-binding `(menu-item
>>>                           "" outline-cycle
>>>                           ;; Only takes effect if point is on a heading.
>>>                           :filter ,(lambda (cmd)
>>> -                                    (when (outline-on-heading-p) cmd)))))
>>> +                                    (when (and (outline-on-heading-p)
>>> +                                               (or (not (functionp outline-mode-cycle-filter))
>>> +                                                   (funcall outline-mode-cycle-filter)))
>>> +                                      cmd)))))
>>>        (define-key map (kbd "TAB") tab-binding)
>>>        (define-key map (kbd "<backtab>") #'outline-cycle-buffer))
>>>      map)
>>>
>>> Then you can customize it to 'bolp'.
>>
>> I just tried it out, and it looks good. The only thing I wonder is if
>> this should apply to both outline-minor-mode and outline-mode?
>
> FWIW, I think it would be nice to provide a simple way to define other
> “speed keys” in `outline-minor-mode [1], or even provide some
> pre-configured ones [2].
>
> Looking at the code, it seems that adding bindings to
> `outline-mode-cycle-map` would achieve precisely that, but the name
> of the keymap doesn't reflect that.

I would appreciate something like this too, but you are right that it
sounds like a separate functionality. Compared to
outline-mode-cycle-map, this would most certainly have to operate on the
beginning of a line, otherwise apparently random keys would suddenly
throw the user around without them expecting it.

> [1]: Cf. https://orgmode.org/manual/Speed-Keys.html
>
> [2]: I personally use these speed keys in outline-minor-mode, which are
> probably very similar to those from Org mode:
>
>         "<tab>" 'outline-cycle
>         "<backtab>" 'outline-cycle-buffer
>         "f" 'outline-forward-same-level
>         "b" 'outline-backward-same-level
>         "n" 'outline-next-visible-heading
>         "p" 'outline-previous-visible-heading
>         "u" 'outline-up-heading
>         "F" 'outline-move-subtree-down
>         "B" 'outline-move-subtree-up
>         "@" 'outline-mark-subtree

-- 
	Philip Kaludercic





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#50679: 28.0.50; outline-minor-mode-cycle should be able to only cycle at the begining of a line
  2021-09-21 11:27             ` Philip Kaludercic
@ 2021-09-21 11:44               ` Augusto Stoffel
  2021-09-21 11:58                 ` Philip Kaludercic
  0 siblings, 1 reply; 21+ messages in thread
From: Augusto Stoffel @ 2021-09-21 11:44 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: 50679, Juri Linkov

On Tue, 21 Sep 2021 at 11:27, Philip Kaludercic <philipk@posteo.net> wrote:

> I would appreciate something like this too, but you are right that it
> sounds like a separate functionality. Compared to
> outline-mode-cycle-map, this would most certainly have to operate on the
> beginning of a line, otherwise apparently random keys would suddenly
> throw the user around without them expecting it.

I thought your point was that TAB for cycling also gets in the way if
it's available anywhere other than at the beginning of a line.

So I think it's actually the _same_ functionality, and only the naming
doesn't reflect that.  To put it in a slightly different way, there
would be no need for a `outline-mode-cycle-map' if something called
`outline-speed-keys-map' (a keymap installed only at column 0 of
heading lines) existed.





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#50679: 28.0.50; outline-minor-mode-cycle should be able to only cycle at the begining of a line
  2021-09-21 11:44               ` Augusto Stoffel
@ 2021-09-21 11:58                 ` Philip Kaludercic
  2021-09-21 19:02                   ` Augusto Stoffel
  0 siblings, 1 reply; 21+ messages in thread
From: Philip Kaludercic @ 2021-09-21 11:58 UTC (permalink / raw)
  To: Augusto Stoffel; +Cc: 50679, Juri Linkov

Augusto Stoffel <arstoffel@gmail.com> writes:

> On Tue, 21 Sep 2021 at 11:27, Philip Kaludercic <philipk@posteo.net> wrote:
>
>> I would appreciate something like this too, but you are right that it
>> sounds like a separate functionality. Compared to
>> outline-mode-cycle-map, this would most certainly have to operate on the
>> beginning of a line, otherwise apparently random keys would suddenly
>> throw the user around without them expecting it.
>
> I thought your point was that TAB for cycling also gets in the way if
> it's available anywhere other than at the beginning of a line.

Yes, but Juri is right that there is a more general issue that tab is
never always appropriate. Just yesterday I ran into the edge-case of
trying to indent a line inwards, and instead of indenting it folded the
definition, because the line unintentionally began with outline-regexp.

> So I think it's actually the _same_ functionality, and only the naming
> doesn't reflect that.  To put it in a slightly different way, there
> would be no need for a `outline-mode-cycle-map' if something called
> `outline-speed-keys-map' (a keymap installed only at column 0 of
> heading lines) existed.

How about both? If you just want to press tab anywhere, use cycle, and
otherwise use speed-keys? Or would that be overkill?

-- 
	Philip Kaludercic





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#50679: 28.0.50; outline-minor-mode-cycle should be able to only cycle at the begining of a line
  2021-09-20 15:35         ` Philip Kaludercic
  2021-09-20 18:36           ` Augusto Stoffel
@ 2021-09-21 17:53           ` Juri Linkov
  2021-09-23 16:17           ` Juri Linkov
  2 siblings, 0 replies; 21+ messages in thread
From: Juri Linkov @ 2021-09-21 17:53 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: 50679

>> Then you can customize it to 'bolp'.
>
> I just tried it out, and it looks good. The only thing I wonder is if
> this should apply to both outline-minor-mode and outline-mode?

You are right, this problem exists only for outline-minor-mode,
so it should be rather:

    :filter ,(lambda (cmd)
               (when (and (outline-on-heading-p)
                          (or (not outline-minor-mode)
                              (not (functionp outline-minor-mode-cycle-filter))
                              (funcall outline-minor-mode-cycle-filter)))
                 cmd))





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#50679: 28.0.50; outline-minor-mode-cycle should be able to only cycle at the begining of a line
  2021-09-20 18:36           ` Augusto Stoffel
  2021-09-21 11:27             ` Philip Kaludercic
@ 2021-09-21 17:58             ` Juri Linkov
  2021-09-21 18:50               ` Augusto Stoffel
  2021-09-23 16:15             ` Juri Linkov
  2 siblings, 1 reply; 21+ messages in thread
From: Juri Linkov @ 2021-09-21 17:58 UTC (permalink / raw)
  To: Augusto Stoffel; +Cc: Philip Kaludercic, 50679

> FWIW, I think it would be nice to provide a simple way to define other
> “speed keys” in `outline-minor-mode [1], or even provide some
> pre-configured ones [2].
>
> [2]: I personally use these speed keys in outline-minor-mode, which are
> probably very similar to those from Org mode:
>
>         "<tab>" 'outline-cycle
>         "<backtab>" 'outline-cycle-buffer
>         "f" 'outline-forward-same-level
>         "b" 'outline-backward-same-level
>         "n" 'outline-next-visible-heading
>         "p" 'outline-previous-visible-heading
>         "u" 'outline-up-heading
>         "F" 'outline-move-subtree-down
>         "B" 'outline-move-subtree-up
>         "@" 'outline-mark-subtree

But this means you can't type all these keys on heading lines?
This is why I confugured it not to use self-inserting keys:

  (let ((map outline-mode-cycle-map)
        (cmds '(("M-<down>"  outline-next-visible-heading)
                ("M-<up>"    outline-previous-visible-heading)
                ("M-<left>"  outline-hide-subtree)
                ("M-<right>" outline-show-subtree))))
    (dolist (command cmds)
      (define-key map (kbd (nth 0 command))
        `(menu-item
          "" ,(nth 1 command)
          :filter ,(lambda (cmd)
                     (when (outline-on-heading-p))
                       cmd))))))


> Looking at the code, it seems that adding bindings to
> `outline-mode-cycle-map` would achieve precisely that, but the name
> of the keymap doesn't reflect that.

Do you suggest different keymaps?  And indeed, these two are
quite different beasts each with own problems.  So we need both
outline-mode-cycle-map and outline-minor-mode-cycle-map.





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#50679: 28.0.50; outline-minor-mode-cycle should be able to only cycle at the begining of a line
  2021-09-21 17:58             ` Juri Linkov
@ 2021-09-21 18:50               ` Augusto Stoffel
  2021-09-22 16:09                 ` Juri Linkov
  0 siblings, 1 reply; 21+ messages in thread
From: Augusto Stoffel @ 2021-09-21 18:50 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Philip Kaludercic, 50679

On Tue, 21 Sep 2021 at 20:58, Juri Linkov <juri@linkov.net> wrote:

>> FWIW, I think it would be nice to provide a simple way to define other
>> “speed keys” in `outline-minor-mode [1], or even provide some
>> pre-configured ones [2].
>>
>> [2]: I personally use these speed keys in outline-minor-mode, which are
>> probably very similar to those from Org mode:
>>
>>         "<tab>" 'outline-cycle
>>         "<backtab>" 'outline-cycle-buffer
>>         "f" 'outline-forward-same-level
>>         "b" 'outline-backward-same-level
>>         "n" 'outline-next-visible-heading
>>         "p" 'outline-previous-visible-heading
>>         "u" 'outline-up-heading
>>         "F" 'outline-move-subtree-down
>>         "B" 'outline-move-subtree-up
>>         "@" 'outline-mark-subtree
>
> But this means you can't type all these keys on heading lines?
> This is why I confugured it not to use self-inserting keys:
>

In my setup those keys only apply at BOL in a heading line.  I never
type anything there.

TAB for reindenting might be a bit trickier.  Apparently I never try to
reindent a heading line when point is at BOL, because I never thought
about a possible conflict, but I guess I would type SPC TAB in that
case.

>   (let ((map outline-mode-cycle-map)
>         (cmds '(("M-<down>"  outline-next-visible-heading)
>                 ("M-<up>"    outline-previous-visible-heading)
>                 ("M-<left>"  outline-hide-subtree)
>                 ("M-<right>" outline-show-subtree))))
>     (dolist (command cmds)
>       (define-key map (kbd (nth 0 command))
>         `(menu-item
>           "" ,(nth 1 command)
>           :filter ,(lambda (cmd)
>                      (when (outline-on-heading-p))
>                        cmd))))))
>
>

I can't find this block in outline.el, is this a suggestion for a
possible default?

>> Looking at the code, it seems that adding bindings to
>> `outline-mode-cycle-map` would achieve precisely that, but the name
>> of the keymap doesn't reflect that.
>
> Do you suggest different keymaps?  And indeed, these two are
> quite different beasts each with own problems.  So we need both
> outline-mode-cycle-map and outline-minor-mode-cycle-map.

Okay, those keymaps are active in the entire heading line, right?

I would prefer to only have a special behavior at the first character of
a heading line, in exchange of allowing _any_ shortcut key with minimal
interference.  Org mode already does that with a simple customization,
(setq org-use-speed-commands t), so I don't think it would be too
surprising for most users.





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#50679: 28.0.50; outline-minor-mode-cycle should be able to only cycle at the begining of a line
  2021-09-21 11:58                 ` Philip Kaludercic
@ 2021-09-21 19:02                   ` Augusto Stoffel
  0 siblings, 0 replies; 21+ messages in thread
From: Augusto Stoffel @ 2021-09-21 19:02 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: 50679, Juri Linkov

On Tue, 21 Sep 2021 at 11:58, Philip Kaludercic <philipk@posteo.net> wrote:

> Yes, but Juri is right that there is a more general issue that tab is
> never always appropriate. Just yesterday I ran into the edge-case of
> trying to indent a line inwards, and instead of indenting it folded the
> definition, because the line unintentionally began with outline-regexp.
>

Okay, this is not an issue for me, but if it happens to you, then it
will happen to other people as well.

>> So I think it's actually the _same_ functionality, and only the naming
>> doesn't reflect that.  To put it in a slightly different way, there
>> would be no need for a `outline-mode-cycle-map' if something called
>> `outline-speed-keys-map' (a keymap installed only at column 0 of
>> heading lines) existed.
>
> How about both? If you just want to press tab anywhere, use cycle, and
> otherwise use speed-keys? Or would that be overkill?

Well, menu items are a bit obscure but not too hard to use, actually.
So I would say that it only makes sense to attempt to provide some
built-in speed key functionality if it's easier to use and customize
than the existing alternative.





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#50679: 28.0.50; outline-minor-mode-cycle should be able to only cycle at the begining of a line
  2021-09-21 18:50               ` Augusto Stoffel
@ 2021-09-22 16:09                 ` Juri Linkov
  2021-09-22 16:30                   ` Augusto Stoffel
  0 siblings, 1 reply; 21+ messages in thread
From: Juri Linkov @ 2021-09-22 16:09 UTC (permalink / raw)
  To: Augusto Stoffel; +Cc: Philip Kaludercic, 50679

>>>         "<tab>" 'outline-cycle
>>>         "<backtab>" 'outline-cycle-buffer
>>>         "f" 'outline-forward-same-level
>>>         "b" 'outline-backward-same-level
>>>         "n" 'outline-next-visible-heading
>>>         "p" 'outline-previous-visible-heading
>>>         "u" 'outline-up-heading
>>>         "F" 'outline-move-subtree-down
>>>         "B" 'outline-move-subtree-up
>>>         "@" 'outline-mark-subtree
>>
>> But this means you can't type all these keys on heading lines?
>> This is why I confugured it not to use self-inserting keys:
>
> In my setup those keys only apply at BOL in a heading line.  I never
> type anything there.
>
> TAB for reindenting might be a bit trickier.  Apparently I never try to
> reindent a heading line when point is at BOL, because I never thought
> about a possible conflict, but I guess I would type SPC TAB in that
> case.

This is exactly what I do every time, i.e. first I type TAB to indent,
but it hides the body, then I type again TAB to unhide the body
to revert the mistake, then type SPC TAB to workaround this annoyance.

>>   (let ((map outline-mode-cycle-map)
>>         (cmds '(("M-<down>"  outline-next-visible-heading)
>>                 ("M-<up>"    outline-previous-visible-heading)
>>                 ("M-<left>"  outline-hide-subtree)
>>                 ("M-<right>" outline-show-subtree))))
>>     (dolist (command cmds)
>>       (define-key map (kbd (nth 0 command))
>>         `(menu-item
>>           "" ,(nth 1 command)
>>           :filter ,(lambda (cmd)
>>                      (when (outline-on-heading-p))
>>                        cmd))))))
>
> I can't find this block in outline.el, is this a suggestion for a
> possible default?

This is from my init file.  I don't suggest to add it to outline.el,
it only shows how it's possible to customize navigation keys.

>>> Looking at the code, it seems that adding bindings to
>>> `outline-mode-cycle-map` would achieve precisely that, but the name
>>> of the keymap doesn't reflect that.
>>
>> Do you suggest different keymaps?  And indeed, these two are
>> quite different beasts each with own problems.  So we need both
>> outline-mode-cycle-map and outline-minor-mode-cycle-map.
>
> Okay, those keymaps are active in the entire heading line, right?
>
> I would prefer to only have a special behavior at the first character of
> a heading line,

Philip already proposed a predicate that can be set to 'bolp'
to make the map active only on the first character.

> in exchange of allowing _any_ shortcut key with minimal
> interference.  Org mode already does that with a simple customization,
> (setq org-use-speed-commands t), so I don't think it would be too
> surprising for most users.

Adding more keys to this keymap has more problems.  For example,
in diff-mode TAB navigates to the next hunk, but with outline-minor-mode
TAB on the first character in a diff-mode buffer cycles the outline,
so another available key 'n' should be typed to navigate to the next hunk.
We can't sacrifice this key for outline-next-visible-heading,
because no more keys will remain for diff-hunk-next.





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#50679: 28.0.50; outline-minor-mode-cycle should be able to only cycle at the begining of a line
  2021-09-22 16:09                 ` Juri Linkov
@ 2021-09-22 16:30                   ` Augusto Stoffel
  0 siblings, 0 replies; 21+ messages in thread
From: Augusto Stoffel @ 2021-09-22 16:30 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Philip Kaludercic, 50679

On Wed, 22 Sep 2021 at 19:09, Juri Linkov <juri@linkov.net> wrote:

>> In my setup those keys only apply at BOL in a heading line.  I never
>> type anything there.
>>
>> TAB for reindenting might be a bit trickier.  Apparently I never try to
>> reindent a heading line when point is at BOL, because I never thought
>> about a possible conflict, but I guess I would type SPC TAB in that
>> case.
>
> This is exactly what I do every time, i.e. first I type TAB to indent,
> but it hides the body, then I type again TAB to unhide the body
> to revert the mistake, then type SPC TAB to workaround this annoyance.

All right, I didn't think this would be a problem for others, but
obviously it is.  In this case (and also taking the diff-mode issue into
account) I guess I'll take back my previous comments.

>> in exchange of allowing _any_ shortcut key with minimal
>> interference.  Org mode already does that with a simple customization,
>> (setq org-use-speed-commands t), so I don't think it would be too
>> surprising for most users.
>
> Adding more keys to this keymap has more problems.  For example,
> in diff-mode TAB navigates to the next hunk, but with outline-minor-mode
> TAB on the first character in a diff-mode buffer cycles the outline,
> so another available key 'n' should be typed to navigate to the next hunk.
> We can't sacrifice this key for outline-next-visible-heading,
> because no more keys will remain for diff-hunk-next.





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#50679: 28.0.50; outline-minor-mode-cycle should be able to only cycle at the begining of a line
  2021-09-20 18:36           ` Augusto Stoffel
  2021-09-21 11:27             ` Philip Kaludercic
  2021-09-21 17:58             ` Juri Linkov
@ 2021-09-23 16:15             ` Juri Linkov
  2 siblings, 0 replies; 21+ messages in thread
From: Juri Linkov @ 2021-09-23 16:15 UTC (permalink / raw)
  To: Augusto Stoffel; +Cc: Philip Kaludercic, 50679

> FWIW, I think it would be nice to provide a simple way to define other
> “speed keys” in `outline-minor-mode [1], or even provide some
> pre-configured ones [2].
>
> Looking at the code, it seems that adding bindings to
> `outline-mode-cycle-map` would achieve precisely that, but the name
> of the keymap doesn't reflect that.

You are right, the name of the keymap was wrong, so I renamed it.

> [2]: I personally use these speed keys in outline-minor-mode, which are
> probably very similar to those from Org mode:
>
>         "<tab>" 'outline-cycle
>         "<backtab>" 'outline-cycle-buffer
>         "f" 'outline-forward-same-level
>         "b" 'outline-backward-same-level
>         "n" 'outline-next-visible-heading
>         "p" 'outline-previous-visible-heading
>         "u" 'outline-up-heading
>         "F" 'outline-move-subtree-down
>         "B" 'outline-move-subtree-up
>         "@" 'outline-mark-subtree

Now it's very easy to copy keys from outline-mode-prefix-map to
outline-minor-mode-cycle-map with just:

```
(map-keymap (lambda (key binding)
              (outline-minor-mode-cycle--bind
               outline-minor-mode-cycle-map
               (vector key) binding))
            outline-mode-prefix-map)
```





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#50679: 28.0.50; outline-minor-mode-cycle should be able to only cycle at the begining of a line
  2021-09-20 15:35         ` Philip Kaludercic
  2021-09-20 18:36           ` Augusto Stoffel
  2021-09-21 17:53           ` Juri Linkov
@ 2021-09-23 16:17           ` Juri Linkov
  2021-09-26 13:59             ` Philip Kaludercic
  2 siblings, 1 reply; 21+ messages in thread
From: Juri Linkov @ 2021-09-23 16:17 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: 50679

tags 50679 fixed
close 50679 28.0.50
thanks

>> Then you can customize it to 'bolp'.
>
> I just tried it out, and it looks good. The only thing I wonder is if
> this should apply to both outline-minor-mode and outline-mode?

I separated maps outline-mode-map from outline-minor-mode-cycle-map,
so it's applied only to outline-minor-mode-cycle-map.  It seems there is
no need to use it in outline-mode.





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#50679: 28.0.50; outline-minor-mode-cycle should be able to only cycle at the begining of a line
  2021-09-23 16:17           ` Juri Linkov
@ 2021-09-26 13:59             ` Philip Kaludercic
  2021-09-27 15:35               ` Juri Linkov
  0 siblings, 1 reply; 21+ messages in thread
From: Philip Kaludercic @ 2021-09-26 13:59 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 50679

Juri Linkov <juri@linkov.net> writes:

> tags 50679 fixed
> close 50679 28.0.50
> thanks
>
>>> Then you can customize it to 'bolp'.
>>
>> I just tried it out, and it looks good. The only thing I wonder is if
>> this should apply to both outline-minor-mode and outline-mode?
>
> I separated maps outline-mode-map from outline-minor-mode-cycle-map,
> so it's applied only to outline-minor-mode-cycle-map.  It seems there is
> no need to use it in outline-mode.

I just noticed this now, but I am not sure how clever it is to bind
outline-cycle-buffer via a menu-item. I don't think that there is as
much of a conflict with backtab, as with regular tab, and having to find
a heading before being able to cycling seems less efficient.

-- 
	Philip Kaludercic





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#50679: 28.0.50; outline-minor-mode-cycle should be able to only cycle at the begining of a line
  2021-09-26 13:59             ` Philip Kaludercic
@ 2021-09-27 15:35               ` Juri Linkov
  2021-09-27 16:16                 ` Augusto Stoffel
  0 siblings, 1 reply; 21+ messages in thread
From: Juri Linkov @ 2021-09-27 15:35 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: 50679

>>>> Then you can customize it to 'bolp'.
>>>
>>> I just tried it out, and it looks good. The only thing I wonder is if
>>> this should apply to both outline-minor-mode and outline-mode?
>>
>> I separated maps outline-mode-map from outline-minor-mode-cycle-map,
>> so it's applied only to outline-minor-mode-cycle-map.  It seems there is
>> no need to use it in outline-mode.
>
> I just noticed this now, but I am not sure how clever it is to bind
> outline-cycle-buffer via a menu-item. I don't think that there is as
> much of a conflict with backtab, as with regular tab, and having to find
> a heading before being able to cycling seems less efficient.

I'm using S-TAB (backtab) all the time, e.g. to move to the previous
hunk in diff-mode, so menu-item is a saver.  After customizing
the option that you proposed to the value "Not at the beginning of the line"
now it's possible to use TAB to move the next diff hunk and S-TAB to
move to the previous diff hunk while keeping point on the first column.
And when point is on the second column then S-TAB hides all hunks,
and TAB opens the current hunk with outline-minor-mode-cycle.





^ permalink raw reply	[flat|nested] 21+ messages in thread

* bug#50679: 28.0.50; outline-minor-mode-cycle should be able to only cycle at the begining of a line
  2021-09-27 15:35               ` Juri Linkov
@ 2021-09-27 16:16                 ` Augusto Stoffel
  0 siblings, 0 replies; 21+ messages in thread
From: Augusto Stoffel @ 2021-09-27 16:16 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Philip Kaludercic, 50679

On Mon, 27 Sep 2021 at 18:35, Juri Linkov <juri@linkov.net> wrote:

>>>>> Then you can customize it to 'bolp'.
>>>>
>>>> I just tried it out, and it looks good. The only thing I wonder is if
>>>> this should apply to both outline-minor-mode and outline-mode?
>>>
>>> I separated maps outline-mode-map from outline-minor-mode-cycle-map,
>>> so it's applied only to outline-minor-mode-cycle-map.  It seems there is
>>> no need to use it in outline-mode.
>>
>> I just noticed this now, but I am not sure how clever it is to bind
>> outline-cycle-buffer via a menu-item. I don't think that there is as
>> much of a conflict with backtab, as with regular tab, and having to find
>> a heading before being able to cycling seems less efficient.

The way I solve this problem is by calling `outline-back-to-heading'
(which, strangely, is not an interactive command).  After that, I have
access to all “speed keys”.  This works almost like a transient keymap.

Actually, I have a DWIM command that calls `outline-up-heading' if
already at a heading and `outline-back-to-heading' otherwise.  I'm not
sure whether such a command would be deemed generally useful or just a
bit too weird.

> I'm using S-TAB (backtab) all the time, e.g. to move to the previous
> hunk in diff-mode, so menu-item is a saver.  After customizing
> the option that you proposed to the value "Not at the beginning of the line"
> now it's possible to use TAB to move the next diff hunk and S-TAB to
> move to the previous diff hunk while keeping point on the first column.
> And when point is on the second column then S-TAB hides all hunks,
> and TAB opens the current hunk with outline-minor-mode-cycle.






^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2021-09-27 16:16 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-19 16:24 bug#50679: 28.0.50; outline-minor-mode-cycle should be able to only cycle at the begining of a line Philip Kaludercic
2021-09-19 16:53 ` Juri Linkov
2021-09-19 20:40   ` Philip Kaludercic
2021-09-20  7:02     ` Juri Linkov
2021-09-20 15:25       ` Juri Linkov
2021-09-20 15:35         ` Philip Kaludercic
2021-09-20 18:36           ` Augusto Stoffel
2021-09-21 11:27             ` Philip Kaludercic
2021-09-21 11:44               ` Augusto Stoffel
2021-09-21 11:58                 ` Philip Kaludercic
2021-09-21 19:02                   ` Augusto Stoffel
2021-09-21 17:58             ` Juri Linkov
2021-09-21 18:50               ` Augusto Stoffel
2021-09-22 16:09                 ` Juri Linkov
2021-09-22 16:30                   ` Augusto Stoffel
2021-09-23 16:15             ` Juri Linkov
2021-09-21 17:53           ` Juri Linkov
2021-09-23 16:17           ` Juri Linkov
2021-09-26 13:59             ` Philip Kaludercic
2021-09-27 15:35               ` Juri Linkov
2021-09-27 16:16                 ` Augusto Stoffel

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).