unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#29081: 25.1; define-globalized-minor-mode does not respect :variable of original mode
@ 2017-10-31 12:29 Chris Stj
  2017-12-02 19:04 ` Noam Postavsky
  0 siblings, 1 reply; 3+ messages in thread
From: Chris Stj @ 2017-10-31 12:29 UTC (permalink / raw)
  To: 29081

I tried to define a global version of auto-fill mode by evaluating

  (define-globalized-minor-mode global-auto-fill-mode auto-fill-mode
    turn-on-auto-fill)

The problem is that when the define-globalized-minor-mode macro expands,
it defines the function

       (defun ,MODE-enable-in-buffers ()
	 (dolist (buf ,MODE-buffers)
	   (when (buffer-live-p buf)
	     (with-current-buffer buf
               (unless ,MODE-set-explicitly
		 (unless (eq ,MODE-major-mode major-mode)
		   (if ,mode
		       (progn
			 (,mode -1)
			 (funcall #',turn-on))
		     (funcall #',turn-on))))
	       (setq ,MODE-major-mode major-mode)))))

The problem lies in the "if ,mode" condition. This assumes the minor
mode variable has the same name as the minor mode itself; which is
clearly not true when something else is specified with the :variable
keyword in the minor mode definition.

I noticed this with auto-fill-mode, since it calls its status variable
auto-fill-function rather than auto-fill-mode.

I guess the best solution may be to allow users of
define-globalized-minor-mode to specify the place in which the minor
mode stores its state, since I can't find a good, generic way to extract
this from the minor mode definition itself, after the fact.

Regards,
Chris





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

* bug#29081: 25.1; define-globalized-minor-mode does not respect :variable of original mode
  2017-10-31 12:29 bug#29081: 25.1; define-globalized-minor-mode does not respect :variable of original mode Chris Stj
@ 2017-12-02 19:04 ` Noam Postavsky
  2021-02-04 14:23   ` Lars Ingebrigtsen
  0 siblings, 1 reply; 3+ messages in thread
From: Noam Postavsky @ 2017-12-02 19:04 UTC (permalink / raw)
  To: Chris Stj; +Cc: 29081

tags 29081 + confirmed easy
quit

k@rdw.se (Chris Stj) writes:

> The problem lies in the "if ,mode" condition. This assumes the minor
> mode variable has the same name as the minor mode itself; which is
> clearly not true when something else is specified with the :variable
> keyword in the minor mode definition.

> I guess the best solution may be to allow users of
> define-globalized-minor-mode to specify the place in which the minor
> mode stores its state, since I can't find a good, generic way to extract
> this from the minor mode definition itself, after the fact.

Makes sense to me.





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

* bug#29081: 25.1; define-globalized-minor-mode does not respect :variable of original mode
  2017-12-02 19:04 ` Noam Postavsky
@ 2021-02-04 14:23   ` Lars Ingebrigtsen
  0 siblings, 0 replies; 3+ messages in thread
From: Lars Ingebrigtsen @ 2021-02-04 14:23 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: 29081, Chris Stj

Noam Postavsky <npostavs@users.sourceforge.net> writes:

>> I guess the best solution may be to allow users of
>> define-globalized-minor-mode to specify the place in which the minor
>> mode stores its state, since I can't find a good, generic way to extract
>> this from the minor mode definition itself, after the fact.
>
> Makes sense to me.

Me too, so I've added this to Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

end of thread, other threads:[~2021-02-04 14:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-31 12:29 bug#29081: 25.1; define-globalized-minor-mode does not respect :variable of original mode Chris Stj
2017-12-02 19:04 ` Noam Postavsky
2021-02-04 14:23   ` Lars Ingebrigtsen

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