unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#64177: outline-minor-mode-highlight fails to activate for custom headings
@ 2023-06-19 20:13 uzibalqa via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-06-20  6:50 ` Juri Linkov
  0 siblings, 1 reply; 10+ messages in thread
From: uzibalqa via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-06-19 20:13 UTC (permalink / raw)
  To: 64177

I have made custom headings for outline-minor-mode 

But

(setq outline-minor-mode-highlight 'override)

does not succeed in displaying the foreground colours at the
defined levels when using

(set-face-foreground "outline-1" "#ff62d4")
(set-face-foreground "outline-2" "#9f80ff")
(set-face-foreground "outline-3" "#fe6060")

Yet, the colours get properly displayed for the default headings
for the specific major mode






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

* bug#64177: outline-minor-mode-highlight fails to activate for custom headings
  2023-06-19 20:13 bug#64177: outline-minor-mode-highlight fails to activate for custom headings uzibalqa via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-06-20  6:50 ` Juri Linkov
  2023-06-20 10:55   ` uzibalqa via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 10+ messages in thread
From: Juri Linkov @ 2023-06-20  6:50 UTC (permalink / raw)
  To: uzibalqa; +Cc: 64177

> I have made custom headings for outline-minor-mode
>
> But
>
> (setq outline-minor-mode-highlight 'override)
>
> does not succeed in displaying the foreground colours at the
> defined levels when using
>
> (set-face-foreground "outline-1" "#ff62d4")
> (set-face-foreground "outline-2" "#9f80ff")
> (set-face-foreground "outline-3" "#fe6060")
>
> Yet, the colours get properly displayed for the default headings
> for the specific major mode

Thanks for the bug report.  It's still not clear how to test it.
When tried to evaluate (set-face-foreground "outline-1" "#ff62d4")
it failed with Lisp error: (wrong-type-argument symbolp "outline-1")
because the right syntax is (set-face-foreground 'outline-1 "#ff62d4").
Does it work with this fix?





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

* bug#64177: outline-minor-mode-highlight fails to activate for custom headings
  2023-06-20  6:50 ` Juri Linkov
@ 2023-06-20 10:55   ` uzibalqa via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-06-20 16:50     ` Juri Linkov
  0 siblings, 1 reply; 10+ messages in thread
From: uzibalqa via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-06-20 10:55 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 64177


------- Original Message -------
On Tuesday, June 20th, 2023 at 6:50 PM, Juri Linkov <juri@linkov.net> wrote:


> > I have made custom headings for outline-minor-mode
> > 
> > But
> > 
> > (setq outline-minor-mode-highlight 'override)
> > 
> > does not succeed in displaying the foreground colours at the
> > defined levels when using
> > 
> > (set-face-foreground "outline-1" "#ff62d4")
> > (set-face-foreground "outline-2" "#9f80ff")
> > (set-face-foreground "outline-3" "#fe6060")
> > 
> > Yet, the colours get properly displayed for the default headings
> > for the specific major mode
> 
> 
> Thanks for the bug report. It's still not clear how to test it.
> When tried to evaluate (set-face-foreground "outline-1" "#ff62d4")
> it failed with Lisp error: (wrong-type-argument symbolp "outline-1")
> because the right syntax is (set-face-foreground 'outline-1 "#ff62d4").
> Does it work with this fix?

I have done this and still showing failure upon 'override

(defvar elisp-hglevels
  '( (";;; H1" . 1) (";;; H2" . 2) (";;; H3" . 3) (";;; H4" . 4)
     (";;; H5" . 5) (";;; H6" . 6) (";;; H7" . 7) (";;; H8" . 8) ))

;;-------------

(defun outlhg-regexp ()

  (cond
    ((eq major-mode 'emacs-lisp-mode)
          (let ( (hrklevels elisp-hrklevels) )
            (setq outline-regexp
                  (concat (regexp-opt (mapcar 'car hrklevels)) "\\>"))
            (setq outline-heading-alist hrklevels))) ))

;; ---------

(defun outlhg-tyface ()
  (interactive)

  (let* ( (pigment-darkbg  '("#ff62d4" "#9f80ff" "#fe6060" "#fba849"
                             "#4fe42f" "#4fafff" "#f0dd60" "#FFFFFF"))
          (pigment-lightbg '("#1f1fce" "#006800" "#b60000" "#605b00"
                             "#a8007f" "#005f88" "#904200" "#7f10d0"))
          (pigment
           (if (eq (frame-parameter nil 'background-mode) 'dark)
               pigment-darkbg
             pigment-lightbg)) )

    (dotimes (i 8)
      (let ((hkfc (intern (format "outline-%d" (1+ i))))
            (colr (nth i pigment)))
        (set-face-foreground hkfc colr)))))
 
;;------------- 

(outline-minor-mode 0)
(setq outline-minor-mode-highlight 'override)
(outlhg-regexp)
(outlhg-tyface)
(outline-minor-mode 1)





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

* bug#64177: outline-minor-mode-highlight fails to activate for custom headings
  2023-06-20 10:55   ` uzibalqa via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-06-20 16:50     ` Juri Linkov
  2023-06-20 20:06       ` uzibalqa via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 10+ messages in thread
From: Juri Linkov @ 2023-06-20 16:50 UTC (permalink / raw)
  To: uzibalqa; +Cc: 64177

> I have done this and still showing failure upon 'override
>
> (defvar elisp-hglevels
>   '( (";;; H1" . 1) (";;; H2" . 2) (";;; H3" . 3) (";;; H4" . 4)
>      (";;; H5" . 5) (";;; H6" . 6) (";;; H7" . 7) (";;; H8" . 8) ))
> ...
>     ((eq major-mode 'emacs-lisp-mode)
> ...
> (outline-minor-mode 0)
> (setq outline-minor-mode-highlight 'override)
> (outlhg-regexp)
> (outlhg-tyface)
> (outline-minor-mode 1)

Please also try:

  (setq-local outline-level 'outline-level)

because 'emacs-lisp-mode' overrides the default value
with own 'lisp-outline-level'.





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

* bug#64177: outline-minor-mode-highlight fails to activate for custom headings
  2023-06-20 16:50     ` Juri Linkov
@ 2023-06-20 20:06       ` uzibalqa via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-06-21  6:13         ` Juri Linkov
  0 siblings, 1 reply; 10+ messages in thread
From: uzibalqa via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-06-20 20:06 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 64177


------- Original Message -------
On Wednesday, June 21st, 2023 at 4:50 AM, Juri Linkov <juri@linkov.net> wrote:


> > I have done this and still showing failure upon 'override
> > 
> > (defvar elisp-hglevels
> > '( (";;; H1" . 1) (";;; H2" . 2) (";;; H3" . 3) (";;; H4" . 4)
> > (";;; H5" . 5) (";;; H6" . 6) (";;; H7" . 7) (";;; H8" . 8) ))
> > ...
> > ((eq major-mode 'emacs-lisp-mode)
> > ...
> > (outline-minor-mode 0)
> > (setq outline-minor-mode-highlight 'override)
> > (outlhg-regexp)
> > (outlhg-tyface)
> > (outline-minor-mode 1)
> 
> 
> Please also try:
> 
> (setq-local outline-level 'outline-level)
> 
> because 'emacs-lisp-mode' overrides the default value
> with own 'lisp-outline-level'.

Now that I have tried your suggestion, I can the the requested highlighting.

I see that the value of outline-level is lisp-outline-level.  Whereas with your change
it is outline-level.

In principle, shouldn't outline-level be directly determined by the level specified 
in outline-heading-alist ?  If emacs-lisp-mode sets outline-heading-alist itself
properly then any level information can be extracted from there.  Then the setup would
run more smoothly because it would be consistent with the way one would actually
customise it.








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

* bug#64177: outline-minor-mode-highlight fails to activate for custom headings
  2023-06-20 20:06       ` uzibalqa via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-06-21  6:13         ` Juri Linkov
  2023-06-21 10:14           ` uzibalqa via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 10+ messages in thread
From: Juri Linkov @ 2023-06-21  6:13 UTC (permalink / raw)
  To: uzibalqa; +Cc: 64177

>> > (defvar elisp-hglevels
>> > '( (";;; H1" . 1) (";;; H2" . 2) (";;; H3" . 3) (";;; H4" . 4)
>> > (";;; H5" . 5) (";;; H6" . 6) (";;; H7" . 7) (";;; H8" . 8) ))
>> > ...
>> > ((eq major-mode 'emacs-lisp-mode)
>> > ...
>> >             (setq outline-regexp
>> >                   (concat (regexp-opt (mapcar 'car hrklevels)) "\\>"))
>> >             (setq outline-heading-alist hrklevels))) ))
>> Please also try:
>>
>> (setq-local outline-level 'outline-level)
>>
>> because 'emacs-lisp-mode' overrides the default value
>> with own 'lisp-outline-level'.
>
> Now that I have tried your suggestion, I can the the requested highlighting.
>
> I see that the value of outline-level is lisp-outline-level.  Whereas with your change
> it is outline-level.
>
> In principle, shouldn't outline-level be directly determined by the level specified
> in outline-heading-alist ?  If emacs-lisp-mode sets outline-heading-alist itself
> properly then any level information can be extracted from there.  Then the setup would
> run more smoothly because it would be consistent with the way one would actually
> customise it.

This makes sense.  OTOH, if we will change the logic, it might break existing code?

Current situation:

  (defun outline-level ()
    (or (cdr (assoc (match-string 0) outline-heading-alist))
        (- (match-end 0) (match-beginning 0))))

but many modes override this default with own function that ignores
outline-heading-alist:

  lisp-outline-level, c-outline-level, cperl-outline-level, perl-outline-level,
  tcl-outline-level, cfengine2-outline-level, conf-outline-level,
  nroff-outline-level, latex-outline-level

- all these ignore outline-heading-alist.

To support outline-heading-alist unconditionally the current calls

  (funcall outline-level)

in many places should be replaced with

  (or (cdr (assoc (match-string 0) outline-heading-alist))
      (funcall outline-level))

I don't think this is feasible, so probably we need only
to add a warning to the docstring of outline-heading-alist.





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

* bug#64177: outline-minor-mode-highlight fails to activate for custom headings
  2023-06-21  6:13         ` Juri Linkov
@ 2023-06-21 10:14           ` uzibalqa via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-06-21 15:58             ` Juri Linkov
  0 siblings, 1 reply; 10+ messages in thread
From: uzibalqa via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-06-21 10:14 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 64177


------- Original Message -------
On Wednesday, June 21st, 2023 at 6:13 PM, Juri Linkov <juri@linkov.net> wrote:


> > > > (defvar elisp-hglevels
> > > > '( (";;; H1" . 1) (";;; H2" . 2) (";;; H3" . 3) (";;; H4" . 4)
> > > > (";;; H5" . 5) (";;; H6" . 6) (";;; H7" . 7) (";;; H8" . 8) ))
> > > > ...
> > > > ((eq major-mode 'emacs-lisp-mode)
> > > > ...
> > > > (setq outline-regexp
> > > > (concat (regexp-opt (mapcar 'car hrklevels)) "\\>"))
> > > > (setq outline-heading-alist hrklevels))) ))
> > > > Please also try:
> > > 
> > > (setq-local outline-level 'outline-level)
> > > 
> > > because 'emacs-lisp-mode' overrides the default value
> > > with own 'lisp-outline-level'.
> > 
> > Now that I have tried your suggestion, I can the the requested highlighting.
> > 
> > I see that the value of outline-level is lisp-outline-level. Whereas with your change
> > it is outline-level.
> > 
> > In principle, shouldn't outline-level be directly determined by the level specified
> > in outline-heading-alist ? If emacs-lisp-mode sets outline-heading-alist itself
> > properly then any level information can be extracted from there. Then the setup would
> > run more smoothly because it would be consistent with the way one would actually
> > customise it.
> 
> 
> This makes sense. OTOH, if we will change the logic, it might break existing code?
> 
> Current situation:
> 
> (defun outline-level ()
> (or (cdr (assoc (match-string 0) outline-heading-alist))
> (- (match-end 0) (match-beginning 0))))
> 
> but many modes override this default with own function that ignores
> outline-heading-alist:
> 
> lisp-outline-level, c-outline-level, cperl-outline-level, perl-outline-level,
> tcl-outline-level, cfengine2-outline-level, conf-outline-level,
> nroff-outline-level, latex-outline-level
> 
> - all these ignore outline-heading-alist.
> 
> To support outline-heading-alist unconditionally the current calls
> 
> (funcall outline-level)
> 
> in many places should be replaced with
> 
> (or (cdr (assoc (match-string 0) outline-heading-alist))
> (funcall outline-level))
> 
> I don't think this is feasible, so probably we need only
> to add a warning to the docstring of outline-heading-alist.

In the modes that override the default, outline-level could be
set up to use outline-heading-alist, avoiding the conditional.








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

* bug#64177: outline-minor-mode-highlight fails to activate for custom headings
  2023-06-21 10:14           ` uzibalqa via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-06-21 15:58             ` Juri Linkov
  2023-06-24 12:21               ` uzibalqa via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 10+ messages in thread
From: Juri Linkov @ 2023-06-21 15:58 UTC (permalink / raw)
  To: uzibalqa; +Cc: 64177

>> but many modes override this default with own function that ignores
>> outline-heading-alist:
>>
>> lisp-outline-level, c-outline-level, cperl-outline-level, perl-outline-level,
>> tcl-outline-level, cfengine2-outline-level, conf-outline-level,
>> nroff-outline-level, latex-outline-level
>>
>> - all these ignore outline-heading-alist.
>
> In the modes that override the default, outline-level could be
> set up to use outline-heading-alist, avoiding the conditional.

Patches are welcome to support outline-heading-alist in the
aforementioned functions.





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

* bug#64177: outline-minor-mode-highlight fails to activate for custom headings
  2023-06-21 15:58             ` Juri Linkov
@ 2023-06-24 12:21               ` uzibalqa via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-06-25 17:13                 ` Juri Linkov
  0 siblings, 1 reply; 10+ messages in thread
From: uzibalqa via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-06-24 12:21 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 64177


------- Original Message -------
On Thursday, June 22nd, 2023 at 3:58 AM, Juri Linkov <juri@linkov.net> wrote:


> > > but many modes override this default with own function that ignores
> > > outline-heading-alist:
> > > 
> > > lisp-outline-level, c-outline-level, cperl-outline-level, perl-outline-level,
> > > tcl-outline-level, cfengine2-outline-level, conf-outline-level,
> > > nroff-outline-level, latex-outline-level
> > > 
> > > - all these ignore outline-heading-alist.
> > 
> > In the modes that override the default, outline-level could be
> > set up to use outline-heading-alist, avoiding the conditional.
> 
> 
> Patches are welcome to support outline-heading-alist in the
> aforementioned functions.

How does emacs-lisp-mode handle outline headings ?  Always setting the
defaults first, then the user can reset the variables outline-regexp, 
outline-heading-alist, and outline-level before enabling outline-minor-mode ?






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

* bug#64177: outline-minor-mode-highlight fails to activate for custom headings
  2023-06-24 12:21               ` uzibalqa via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-06-25 17:13                 ` Juri Linkov
  0 siblings, 0 replies; 10+ messages in thread
From: Juri Linkov @ 2023-06-25 17:13 UTC (permalink / raw)
  To: uzibalqa; +Cc: 64177-done

> How does emacs-lisp-mode handle outline headings ?  Always setting the
> defaults first, then the user can reset the variables outline-regexp,
> outline-heading-alist, and outline-level before enabling outline-minor-mode ?

Yes, you need to set the variables outline-regexp, outline-heading-alist,
and outline-level before enabling outline-minor-mode.

Since you have a working solution now, I'm closing this request.





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

end of thread, other threads:[~2023-06-25 17:13 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-19 20:13 bug#64177: outline-minor-mode-highlight fails to activate for custom headings uzibalqa via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-20  6:50 ` Juri Linkov
2023-06-20 10:55   ` uzibalqa via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-20 16:50     ` Juri Linkov
2023-06-20 20:06       ` uzibalqa via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-21  6:13         ` Juri Linkov
2023-06-21 10:14           ` uzibalqa via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-21 15:58             ` Juri Linkov
2023-06-24 12:21               ` uzibalqa via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-25 17:13                 ` Juri Linkov

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