git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v7 3/3] git-jump: invoke emacs/emacsclient

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Nov 28, 2022, 10:54 UTC
Message-ID
<221128.86cz97mjdj.gmgdl@evledraar.gmail.com>
In-Reply-To
<Y4RC3NZsiy5gXPoJ@coredump.intra.peff.net>
On Mon, Nov 28 2022, Jeff King wrote:
Show 32 quoted lines
> On Sat, Nov 26, 2022 at 12:52:50AM +0100, Ævar Arnfjörð Bjarmason wrote:
>
>> > Second, there is a difficulty passing arbitrary arguments properly to
>> > Emacs Lisp properly.
>> > For example, your version will cause error with
>> >         git jump grep "hello world"
>> > My early patch was doing something similar. But the second problem was
>> > hard to deal with,
>> > so I switched to using a temporary file.
>> 
>> To the extent that that's painful couldn't we write the grep expression
>> / arguments to the tempfile, then feed the tempfile to the ad-hoc elisp
>> code?
>> 
>> It would then read it, get the argument to grep for, and we'd call (grep
>> that-argument).
>
> You'd still need to quote the arguments, since you'll be reading
> potentially multiple arguments out of the bytestream of the file[1].
>
> If you're not going to quote, the simplest thing is to generate the
> line-oriented output and read that.
>
> If you are going to quote, then you don't need the tempfile at all. You
> can shove the command into the eval, as if git-jump were run from emacs
> directly (but you want to use the --stdout mode introduced in this
> series, and not the git commands directly, because of course they're
> non-trivial).
>
> I showed how to do the quoting earlier in the thread. But it is ugly,
> and this tempfile hack should work (modulo the gross wait loop
> afterwards).

Thanks, I'd missed https://lore.kernel.org/git/Y30a0ulfxyE7dnYi@coredump.intra.peff.net/

I think the case where the temporary directory itself has spaces in it isn't worth worrying about.

So, all we'd need to worry about is getting the arguments to be grep'd to emacs.

That should be simpler & bug-free with some equivalent of
     echo "args" >$tmpfile
then in Emacs, given some "<tmpfile>" variable:
  (with-temp-buffer
    (insert-file-contents <tempfile>)
    (buffer-string)))
We'd then invoke M-x grep with that.

I think getting rid of the tempfile isn't worth it, or worth worrying about, what I was pointing out is that the implementation as it stands works notably differently than if you invoked M-x grep itself.

I.e. it doesn't do highlighting, and (I didn't note this before) if it takes a while we'll "hang", if we had emacs itself invoke the "git grep" we'd stream out grep results as they came in.

Previous: Jeff KingNext: Yoichi Nakayama
Message 59 of 68 in “git-jump: support Emacs”
  1. 0/2 git-jump: support EmacsYoichi NAKAYAMA via GitGitGadget, Nov 19, 2022
  2. 1/2 git-jump: add an optional argument 'stdout'Yoichi Nakayama via GitGitGadget, Nov 19, 2022
  3. 2/2 git-jump: invoke emacsclientYoichi Nakayama via GitGitGadget, Nov 19, 2022
  4. Eric SunshineNov 19, 2022
  5. Yoichi NakayamaNov 19, 2022
  6. Eric SunshineNov 19, 2022
  7. Yoichi NakayamaNov 21, 2022
  8. 0/2 git-jump: support EmacsYoichi NAKAYAMA via GitGitGadget, Nov 20, 2022
  9. 1/2 git-jump: add an optional argument 'stdout'Yoichi Nakayama via GitGitGadget, Nov 20, 2022
  10. Junio C HamanoNov 21, 2022
  11. Yoichi NakayamaNov 21, 2022
  12. Jeff KingNov 21, 2022
  13. 2/2 git-jump: invoke emacsclientYoichi Nakayama via GitGitGadget, Nov 20, 2022
  14. 0/2 git-jump: support EmacsYoichi NAKAYAMA via GitGitGadget, Nov 21, 2022
  15. 1/2 git-jump: add an optional argument '--stdout'Yoichi Nakayama via GitGitGadget, Nov 21, 2022
  16. Jeff KingNov 21, 2022
  17. Junio C HamanoNov 21, 2022
  18. Yoichi NakayamaNov 22, 2022
  19. Jeff KingNov 22, 2022
  20. Yoichi NakayamaNov 22, 2022
  21. 2/2 git-jump: invoke emacs/emacsclientYoichi Nakayama via GitGitGadget, Nov 21, 2022
  22. Jeff KingNov 21, 2022
  23. Yoichi NakayamaNov 22, 2022
  24. 0/2 git-jump: support EmacsYoichi NAKAYAMA via GitGitGadget, Nov 22, 2022
  25. 1/2 git-jump: add an optional argument '--stdout'Yoichi Nakayama via GitGitGadget, Nov 22, 2022
  26. Jeff KingNov 22, 2022
  27. 2/2 git-jump: invoke emacs/emacsclientYoichi Nakayama via GitGitGadget, Nov 22, 2022
  28. Phillip WoodNov 22, 2022
  29. Yoichi NakayamaNov 23, 2022
  30. Jeff KingNov 22, 2022
  31. Yoichi NakayamaNov 23, 2022
  32. Jeff KingNov 24, 2022
  33. Yoichi NakayamaNov 24, 2022
  34. Yoichi NakayamaNov 24, 2022
  35. Jeff KingNov 24, 2022
  36. Jeff KingNov 24, 2022
  37. Yoichi NakayamaNov 25, 2022
  38. 0/3 git-jump: support EmacsYoichi NAKAYAMA via GitGitGadget, Nov 23, 2022
  39. 1/3 git-jump: add an optional argument '--stdout'Yoichi Nakayama via GitGitGadget, Nov 23, 2022
  40. 2/3 git-jump: move valid-mode check earlierJeff King via GitGitGadget, Nov 23, 2022
  41. 3/3 git-jump: invoke emacs/emacsclientYoichi Nakayama via GitGitGadget, Nov 23, 2022
  42. Phillip WoodNov 23, 2022
  43. Yoichi NakayamaNov 23, 2022
  44. Jeff KingNov 24, 2022
  45. 0/3 git-jump: support EmacsYoichi NAKAYAMA via GitGitGadget, Nov 24, 2022
  46. 1/3 git-jump: add an optional argument '--stdout'Yoichi Nakayama via GitGitGadget, Nov 24, 2022
  47. 2/3 git-jump: move valid-mode check earlierJeff King via GitGitGadget, Nov 24, 2022
  48. 3/3 git-jump: invoke emacs/emacsclientYoichi Nakayama via GitGitGadget, Nov 24, 2022
  49. 0/3 git-jump: support EmacsYoichi NAKAYAMA via GitGitGadget, Nov 25, 2022
  50. 1/3 git-jump: add an optional argument '--stdout'Yoichi Nakayama via GitGitGadget, Nov 25, 2022
  51. Ævar Arnfjörð BjarmasonNov 25, 2022
  52. Yoichi NakayamaNov 27, 2022
  53. 2/3 git-jump: move valid-mode check earlierJeff King via GitGitGadget, Nov 25, 2022
  54. 3/3 git-jump: invoke emacs/emacsclientYoichi Nakayama via GitGitGadget, Nov 25, 2022
  55. Ævar Arnfjörð BjarmasonNov 25, 2022
  56. Yoichi NakayamaNov 25, 2022
  57. Ævar Arnfjörð BjarmasonNov 25, 2022
  58. Jeff KingNov 28, 2022
  59. Ævar Arnfjörð BjarmasonNov 28, 2022
  60. Yoichi NakayamaNov 28, 2022
  61. Yoichi NakayamaNov 27, 2022
  62. 0/3 git-jump: support EmacsYoichi NAKAYAMA via GitGitGadget, Nov 27, 2022
  63. 1/3 git-jump: add an optional argument '--stdout'Yoichi Nakayama via GitGitGadget, Nov 27, 2022
  64. 2/3 git-jump: move valid-mode check earlierJeff King via GitGitGadget, Nov 27, 2022
  65. 3/3 git-jump: invoke emacs/emacsclientYoichi Nakayama via GitGitGadget, Nov 27, 2022
  66. Phillip WoodNov 28, 2022
  67. Junio C HamanoNov 28, 2022
  68. Yoichi NakayamaNov 29, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.