all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#19492: How to neatly call interactive commands interactively?
@ 2015-01-02 22:09 Reuben Thomas
  2019-08-02 20:24 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 3+ messages in thread
From: Reuben Thomas @ 2015-01-02 22:09 UTC (permalink / raw)
  To: 19492

[-- Attachment #1: Type: text/plain, Size: 790 bytes --]

I wanted to combine a couple of modes for soft-wrapped text, so I wrote:

(defun soft-wrap-modes ()
  (interactive)
  "Turn on minor modes for soft wrap"
  (if (called-interactively-p) (call-interactively
'adaptive-wrap-prefix-mode) (adaptive-wrap-prefix-mode))
  (if (called-interactively-p) (call-interactively 'window-margin-mode)
(window-margin-mode)))

The idea is that soft-wrap-modes should toggle when used interactively,
just like the underlying mode commands. But this is not very nice. It could
be made a bit nicer using map, but is there no way to transparently pass
the interactivity of the current command down to the sub-commands? I
couldn't see a way to do this with the standard methods for testing whether
a command is called in interactive mode.

-- 
http://rrt.sc3d.org

[-- Attachment #2: Type: text/html, Size: 1068 bytes --]

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

* bug#19492: How to neatly call interactive commands interactively?
  2015-01-02 22:09 bug#19492: How to neatly call interactive commands interactively? Reuben Thomas
@ 2019-08-02 20:24 ` Lars Ingebrigtsen
  2019-08-03  2:46   ` Noam Postavsky
  0 siblings, 1 reply; 3+ messages in thread
From: Lars Ingebrigtsen @ 2019-08-02 20:24 UTC (permalink / raw)
  To: Reuben Thomas; +Cc: 19492

Reuben Thomas <rrt@sc3d.org> writes:

> I wanted to combine a couple of modes for soft-wrapped text, so I wrote:
>
> (defun soft-wrap-modes ()
>   (interactive)
>   "Turn on minor modes for soft wrap"
>   (if (called-interactively-p) (call-interactively 'adaptive-wrap-prefix-mode)
> (adaptive-wrap-prefix-mode))
>   (if (called-interactively-p) (call-interactively 'window-margin-mode)
> (window-margin-mode)))
>
> The idea is that soft-wrap-modes should toggle when used interactively, just
> like the underlying mode commands. But this is not very nice. It could be
> made a bit nicer using map, but is there no way to transparently pass the
> interactivity of the current command down to the sub-commands? I couldn't
> see a way to do this with the standard methods for testing whether a
> command is called in interactive mode.

(I'm going through old bug reports that unfortunately have not received
any responses yet.)

I don't think there's any way to do what you want.  (Somebody correct me
if I'm wrong.)  And I don't really see how an interface that does this
would work, really.  Something like

(with-everything-interactive-if-this-is-interactive
  (adaptive-wrap-prefix-mode)
  (window-margin-mode))

Well, in this case that would be a pretty trivial macro to write, but I
don't see this as being generally useful.  So I'm closing this as a
"wontfix".

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





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

* bug#19492: How to neatly call interactive commands interactively?
  2019-08-02 20:24 ` Lars Ingebrigtsen
@ 2019-08-03  2:46   ` Noam Postavsky
  0 siblings, 0 replies; 3+ messages in thread
From: Noam Postavsky @ 2019-08-03  2:46 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 19492, Reuben Thomas

Lars Ingebrigtsen <larsi@gnus.org> writes:

> I don't think there's any way to do what you want.  (Somebody correct me
> if I'm wrong.)  And I don't really see how an interface that does this
> would work, really.  Something like

> (with-everything-interactive-if-this-is-interactive
>   (adaptive-wrap-prefix-mode)
>   (window-margin-mode))

I think it would be more like

    (funcall-preserving-interactiveness 'adaptive-wrap-prefix-mode)
    (funcall-preserving-interactiveness 'window-margin-mode)

The main implementation of this would really be called-interactively-p,
when it examines the call stack.

> Well, in this case that would be a pretty trivial macro to write, but I
> don't see this as being generally useful.  So I'm closing this as a
> "wontfix".

That said, while I don't think it's impossible, I don't know if it's
really worth the trouble.






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

end of thread, other threads:[~2019-08-03  2:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-02 22:09 bug#19492: How to neatly call interactive commands interactively? Reuben Thomas
2019-08-02 20:24 ` Lars Ingebrigtsen
2019-08-03  2:46   ` Noam Postavsky

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.