all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Fix the confliction between lsp-ui-doc-mode and dap-tooltip-mode with advice function.
@ 2021-10-06  8:09 Hongyi Zhao
  2021-10-09  7:42 ` Hongyi Zhao
  0 siblings, 1 reply; 3+ messages in thread
From: Hongyi Zhao @ 2021-10-06  8:09 UTC (permalink / raw)
  To: help-gnu-emacs

Fix the confliction between lsp-ui-doc-mode and dap-tooltip-mode with
advice function.

I'm experiencing the bugs reported here [1]. To be specific, there is
a confliction between `lsp-ui-doc-mode' and `dap-tooltip-mode' when
both of them are enabled, which will cause the debugger not to display
the variable value when the mouse hovers over the corresponding
variable name. And the expedient is to define an advice function which
do the following:

Once I try to run `dap-debug', disable the `lsp-ui-doc-mode' if it has
already been enabled for the current buffer; and enable it when the
`dap-disconnect' command is issued.

I tried the suggested functions here [2], as shown below, but it doesn't work:

(define-advice dap-debug (:after (orig-func &rest args)
disable-lsp-ui-doc) (lsp-ui-doc-mode -1))
(define-advice dap-disconnect (:after (orig-func &rest args)
enable-lsp-ui-doc) (lsp-ui-doc-mode t))

[1] https://github.com/emacs-lsp/dap-mode/issues/372
[2] https://github.com/emacs-lsp/dap-mode/issues/372#issuecomment-848784686

Any hints for adapting or writing a working lisp code snippet for
solving the above problem?

Regards
-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
No. 473, Quannan West Street, Xindu District, Xingtai, Hebei province



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

* Re: Fix the confliction between lsp-ui-doc-mode and dap-tooltip-mode with advice function.
  2021-10-06  8:09 Fix the confliction between lsp-ui-doc-mode and dap-tooltip-mode with advice function Hongyi Zhao
@ 2021-10-09  7:42 ` Hongyi Zhao
  2021-10-09 13:14   ` Hongyi Zhao
  0 siblings, 1 reply; 3+ messages in thread
From: Hongyi Zhao @ 2021-10-09  7:42 UTC (permalink / raw)
  To: help-gnu-emacs

On Wed, Oct 6, 2021 at 4:09 PM Hongyi Zhao <hongyi.zhao@gmail.com> wrote:
>
> Fix the confliction between lsp-ui-doc-mode and dap-tooltip-mode with
> advice function.
>
> I'm experiencing the bugs reported here [1]. To be specific, there is
> a confliction between `lsp-ui-doc-mode' and `dap-tooltip-mode' when
> both of them are enabled, which will cause the debugger not to display
> the variable value when the mouse hovers over the corresponding
> variable name. And the expedient is to define an advice function which
> do the following:
>
> Once I try to run `dap-debug', disable the `lsp-ui-doc-mode' if it has
> already been enabled for the current buffer; and enable it when the
> `dap-disconnect' command is issued.
>
> I tried the suggested functions here [2], as shown below, but it doesn't work:
>
> (define-advice dap-debug (:after (orig-func &rest args)
> disable-lsp-ui-doc) (lsp-ui-doc-mode -1))
> (define-advice dap-disconnect (:after (orig-func &rest args)
> enable-lsp-ui-doc) (lsp-ui-doc-mode t))
>
> [1] https://github.com/emacs-lsp/dap-mode/issues/372
> [2] https://github.com/emacs-lsp/dap-mode/issues/372#issuecomment-848784686
>
> Any hints for adapting or writing a working lisp code snippet for
> solving the above problem?

Based on the document here [1], I figured out the following code
snippet, and it works:

  (defun disable-lsp-ui-doc (orig-fun &rest args)
     (lsp-ui-doc-mode -1))

  (advice-add 'dap-debug :after #'disable-lsp-ui-doc)

  (defun enable-lsp-ui-doc (orig-fun &rest args)
     (lsp-ui-doc-mode))

  (advice-add 'dap-disconnect :after #'enable-lsp-ui-doc)

[1]  https://www.gnu.org/software/emacs/manual/html_mono/elisp.html#Advising-Functions

Regards, HZ



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

* Re: Fix the confliction between lsp-ui-doc-mode and dap-tooltip-mode with advice function.
  2021-10-09  7:42 ` Hongyi Zhao
@ 2021-10-09 13:14   ` Hongyi Zhao
  0 siblings, 0 replies; 3+ messages in thread
From: Hongyi Zhao @ 2021-10-09 13:14 UTC (permalink / raw)
  To: help-gnu-emacs

On Sat, Oct 9, 2021 at 3:42 PM Hongyi Zhao <hongyi.zhao@gmail.com> wrote:
>
> On Wed, Oct 6, 2021 at 4:09 PM Hongyi Zhao <hongyi.zhao@gmail.com> wrote:
> >
> > Fix the confliction between lsp-ui-doc-mode and dap-tooltip-mode with
> > advice function.
> >
> > I'm experiencing the bugs reported here [1]. To be specific, there is
> > a confliction between `lsp-ui-doc-mode' and `dap-tooltip-mode' when
> > both of them are enabled, which will cause the debugger not to display
> > the variable value when the mouse hovers over the corresponding
> > variable name. And the expedient is to define an advice function which
> > do the following:
> >
> > Once I try to run `dap-debug', disable the `lsp-ui-doc-mode' if it has
> > already been enabled for the current buffer; and enable it when the
> > `dap-disconnect' command is issued.
> >
> > I tried the suggested functions here [2], as shown below, but it doesn't work:
> >
> > (define-advice dap-debug (:after (orig-func &rest args)
> > disable-lsp-ui-doc) (lsp-ui-doc-mode -1))
> > (define-advice dap-disconnect (:after (orig-func &rest args)
> > enable-lsp-ui-doc) (lsp-ui-doc-mode t))
> >
> > [1] https://github.com/emacs-lsp/dap-mode/issues/372
> > [2] https://github.com/emacs-lsp/dap-mode/issues/372#issuecomment-848784686
> >
> > Any hints for adapting or writing a working lisp code snippet for
> > solving the above problem?
>
> Based on the document here [1], I figured out the following code
> snippet, and it works:
>
>   (defun disable-lsp-ui-doc (orig-fun &rest args)
>      (lsp-ui-doc-mode -1))
>
>   (advice-add 'dap-debug :after #'disable-lsp-ui-doc)
>
>   (defun enable-lsp-ui-doc (orig-fun &rest args)
>      (lsp-ui-doc-mode))
>
>   (advice-add 'dap-disconnect :after #'enable-lsp-ui-doc)
>
> [1]  https://www.gnu.org/software/emacs/manual/html_mono/elisp.html#Advising-Functions

It seems that I came to the wrong conclusion in a hurry. Based on the
document here [1] and my later tries, the above two method, i.e.,
`define-advice' and `advice-add' are equivalent for the problem
discussed here, but apparently, the `define-advice' method is more
concise.

[1] https://www.gnu.org/software/emacs/manual/html_mono/elisp.html#Advising-Named-Functions

Regards, HZ



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

end of thread, other threads:[~2021-10-09 13:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-06  8:09 Fix the confliction between lsp-ui-doc-mode and dap-tooltip-mode with advice function Hongyi Zhao
2021-10-09  7:42 ` Hongyi Zhao
2021-10-09 13:14   ` Hongyi Zhao

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.