Skip to content

M-i in counsel-compile fails due to propagated 'cmd property #2040

@stsquad

Description

@stsquad

https://github.com/abo-abo/swiper/blob/0e62f0d1f61b825ca5eb4b55e47ecb37b3e2834e/counsel.el#L5379+

I've noticed this recently when trying to use compile targets not in the generated list. We fall-over because we look for the cmd property and unless the new target is exactly the same length it will get it wrong. I've thought of something like the following:

(if (get-char-property 0 'cmd cmd)
    (setq cmd (substring-no-properties
               cmd 0 (next-single-property-change 0 'cmd cmd)))
  (setq cmd (substring-no-properties
             cmd 0 (next-single-property-change 0 'face cmd))))

i.e. fall-back to searching for the change to the face used for in/with to extract the command. However for this to work I should really strip out the 'cmd property on M-i invocations. So this issue is to discuss what the best approach is. I can think of:

  1. custom M-i that replicates ivy-insert-current but with special handling
  2. wrapper M-i that messes with (ivy-state-current ivy-last) somehow - I'm not familiar with how the cl-defstruct stuff works before calling ivy-insert-current
  3. add a hook that ivy-insert-current can process the text with before inserting the string

So @abo-abo which do you think is the best approach? Is there already a mechanism for this sort of thing or is my case too much of a special snowflake because of its heavy use of propertised strings?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions