unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: [elpa] externals/detached 827e3d64fe: Bug fix: Incorrect initialization of projectile
       [not found] ` <20220822195731.3F972C0088A@vcs2.savannah.gnu.org>
@ 2022-08-22 20:15   ` Stefan Monnier
  2022-08-25 18:30     ` Niklas Eklund
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Monnier @ 2022-08-22 20:15 UTC (permalink / raw)
  To: Niklas Eklund; +Cc: emacs-devel

Hi Niklas,

> @@ -150,7 +150,7 @@
>  
>  (defun detached-init--projectile ()
>    "Initialize integration with `projectile'."
> -  (when (functionp #'projectile)
> +  (when (featurep 'projectile)
>      (advice-add 'projectile-run-compilation
>                  :override #'detached-extra-projectile-run-compilation)))
>  

I suspect that you can then also remove the corresponding
`declare-function`.
More importantly, `advice-add` can be used on a symbol whose function is
not yet defined, so you can skip the `when` test altogether.

The same applies to the following:

    (when (functionp #'dired-rsync)
      (advice-add #'dired-rsync--do-run :override #'detached-extra-dired-rsync)))

where my stylistic checker additionally complains about:
- #' kind of says that `dired-rsync` is a function, so using `functionp`
  on it is a bit weird.  Usually, code does (fboundp 'dired-rsync) instead.
- `advice-add` takes as first argument a symbol.  That symbol is
  expected to contains a function, indeed, but it can't just take any
  function (e.g. a (lambda ...) would be an error), for that reason
  I think using ' rather than #' is preferable (e.g. if you consider
  that Common Lisp (and `cl-flet`) will treat #'<symbol> as a reference
  to the function stored in the symbol (much like `symbol-function`)
  rather than as the symbol itself).


        Stefan




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

* Re: [elpa] externals/detached 827e3d64fe: Bug fix: Incorrect initialization of projectile
  2022-08-22 20:15   ` [elpa] externals/detached 827e3d64fe: Bug fix: Incorrect initialization of projectile Stefan Monnier
@ 2022-08-25 18:30     ` Niklas Eklund
  0 siblings, 0 replies; 2+ messages in thread
From: Niklas Eklund @ 2022-08-25 18:30 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

Hi Stefan,

> Hi Niklas,
>
>> @@ -150,7 +150,7 @@
>>  
>>  (defun detached-init--projectile ()
>>    "Initialize integration with `projectile'."
>> -  (when (functionp #'projectile)
>> +  (when (featurep 'projectile)
>>      (advice-add 'projectile-run-compilation
>>                  :override #'detached-extra-projectile-run-compilation)))
>>  
>
> I suspect that you can then also remove the corresponding
> `declare-function`.
> More importantly, `advice-add` can be used on a symbol whose function is
> not yet defined, so you can skip the `when` test altogether.

That's very neat that the check can be skipped, thanks for the
suggestion!

> The same applies to the following:
>
>     (when (functionp #'dired-rsync)
>       (advice-add #'dired-rsync--do-run :override #'detached-extra-dired-rsync)))
>
> where my stylistic checker additionally complains about:
> - #' kind of says that `dired-rsync` is a function, so using `functionp`
>   on it is a bit weird.  Usually, code does (fboundp 'dired-rsync)
> instead.

Aha, I had been thinking it should be quoted since it was a function but
now I understand that better. Btw what stylistic checker are you running
that shows you this? :)

> - `advice-add` takes as first argument a symbol.  That symbol is
>   expected to contains a function, indeed, but it can't just take any
>   function (e.g. a (lambda ...) would be an error), for that reason
>   I think using ' rather than #' is preferable (e.g. if you consider
>   that Common Lisp (and `cl-flet`) will treat #'<symbol> as a reference
>   to the function stored in the symbol (much like `symbol-function`)
>   rather than as the symbol itself).

That make sense with the lambda example, thanks for the explenation!
>
>         Stefan

/Niklas



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

end of thread, other threads:[~2022-08-25 18:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <166119825097.26859.927185263202609197@vcs2.savannah.gnu.org>
     [not found] ` <20220822195731.3F972C0088A@vcs2.savannah.gnu.org>
2022-08-22 20:15   ` [elpa] externals/detached 827e3d64fe: Bug fix: Incorrect initialization of projectile Stefan Monnier
2022-08-25 18:30     ` Niklas Eklund

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