all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Re: [Emacs-diffs] fix/bug-2034 21904f5: Support mode line constructs for 'mode-name' in c-mode (bug#2034)
       [not found] ` <20180703123451.00E9320543@vcs0.savannah.gnu.org>
@ 2018-07-03 21:03   ` Stefan Monnier
  2018-07-03 22:37     ` Phil Sainty
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2018-07-03 21:03 UTC (permalink / raw)
  To: emacs-devel; +Cc: Phil Sainty

> +  (unless c-modeline-flags
> +    (setq mode-name (list "" mode-name (list 'c-modeline-display-flags
> +					     'c-modeline-flags))))
> +  (setq c-modeline-flags
> +	(format "/%s%s%s%s%s"
> +		(if c-block-comment-flag "*" "/")
> +		(if c-electric-flag "l" "")
> +		(if (and c-electric-flag c-auto-newline)
> +		    "a" "")
> +		(if c-hungry-delete-key "h" "")
> +		(if (and
> +		     ;; (cc-)subword might not be loaded.
> +		     (boundp 'c-subword-mode)
> +		     (symbol-value 'c-subword-mode))
> +		    ;; FIXME: subword-mode already comes with its
> +		    ;; own lighter!
> +		    "w"
> +		  "")))

At that point, why use `format` here instead of using mode-line
constructs for everything, as in:

    (setq c-mode-line-flags
          '("/"
            (c-block-comment-flag "*" "/")
            ...))

Then c-update-modeline doesn't need to be called repeatedly since the
refresh is done automatically by force-mode-line-update.


        Stefan



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

* Re: [Emacs-diffs] fix/bug-2034 21904f5: Support mode line constructs for 'mode-name' in c-mode (bug#2034)
  2018-07-03 21:03   ` [Emacs-diffs] fix/bug-2034 21904f5: Support mode line constructs for 'mode-name' in c-mode (bug#2034) Stefan Monnier
@ 2018-07-03 22:37     ` Phil Sainty
  2018-07-03 23:57       ` Phil Sainty
  0 siblings, 1 reply; 3+ messages in thread
From: Phil Sainty @ 2018-07-03 22:37 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Emacs-devel, emacs-devel

On 2018-07-04 09:03, Stefan Monnier wrote:
> At that point, why use `format` here instead of using mode-line
> constructs for everything, as in:
> 
>     (setq c-mode-line-flags
>           '("/"
>             (c-block-comment-flag "*" "/")
>             ...))
> 
> Then c-update-modeline doesn't need to be called repeatedly since the
> refresh is done automatically by force-mode-line-update.

That's true.  It would mean that a bit more work is happening per 
modeline
render, vs only (I think?) calculating the flags when they change; but
assuming that's nothing to worry about, it sounds sensible to me too.


-Phil




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

* Re: [Emacs-diffs] fix/bug-2034 21904f5: Support mode line constructs for 'mode-name' in c-mode (bug#2034)
  2018-07-03 22:37     ` Phil Sainty
@ 2018-07-03 23:57       ` Phil Sainty
  0 siblings, 0 replies; 3+ messages in thread
From: Phil Sainty @ 2018-07-03 23:57 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Emacs-devel, emacs-devel

Grepping for uses of c-update-modeline I found this related comment in
lisp/progmodes/antlr-mode.el:

(define-derived-mode antlr-mode prog-mode
   ;; FIXME: Since it uses cc-mode, it bumps into c-update-modeline's
   ;; limitation to mode-name being a string.
   ;; '("Antlr." (:eval (cadr (assq antlr-language 
antlr-language-alist))))
   "Antlr"

I'll test the commented variant with my other changes in place, but it's 
my
understanding that the NAME argument to `define-derived-mode' *should* 
be a
string, even if the mode's body then sets `mode-name' explicitly to 
something
else.

It's certainly documented that NAME is a string; and if it's not a 
string,
then IIRC you run into problems like antlr-mode-hook's docstring 
containing
the full mode line construct rather than the formatted name.

So I expect to use the following in the mode body:
(setq mode-name '("Antlr." (:eval (cadr (assq antlr-language 
antlr-language-alist)))))


-Phil




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

end of thread, other threads:[~2018-07-03 23:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20180703123449.18179.32328@vcs0.savannah.gnu.org>
     [not found] ` <20180703123451.00E9320543@vcs0.savannah.gnu.org>
2018-07-03 21:03   ` [Emacs-diffs] fix/bug-2034 21904f5: Support mode line constructs for 'mode-name' in c-mode (bug#2034) Stefan Monnier
2018-07-03 22:37     ` Phil Sainty
2018-07-03 23:57       ` Phil Sainty

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.