alezost / guix.el

Emacs interface for GNU Guix package manager
https://emacs-guix.gitlab.io/website/
GNU General Public License v3.0
139 stars 16 forks source link

elisp/devel: Add guix-devel-code-block-edit #13

Closed wigust closed 6 years ago

wigust commented 6 years ago

Hello Alex,

This patch provides functionality similar to Org edit source code block at point. See https://orgmode.org/manual/Editing-source-code.html

It makes little bit easier to edit description and synopsis Guix package fields.

wigust commented 6 years ago

Sorry, I forgot about adding edit-indirect in doc/emacs-guix.texi and elisp/guix.el. I'll do it.

alezost commented 6 years ago

Sorry for the delay and thank you! I made some changes and applied it as fb659907471f278d8aed2fd4a5ecc4683e4ba4ff.

The main change is: I think that using guix-devel-code-block-syntax in the regexp and in the error message is overly complicated, so I just removed it :-)

Also I found that up-list is not reliable: for example, it does something strange when you press C-c ' in the description of emacs-edit-indirect package, so I replaced by forward-sexp.

Let me know if something is not as you think it should be.

wigust commented 6 years ago

I made some changes and applied it as fb65990.

OK, thank you.

Let me know if something is not as you think it should be.

Does texinfo-mode works for you?

For me <C-'> brings a new window in fundamental-mode. I think this is because of edit-indirect-guess-mode-function is not called anywhere.

(defun guix-devel-code-block-edit ()
  ;; …
  (let* (;…
         (edit-indirect-guess-mode-function
          (lambda (&rest _) (texinfo-mode))))
    (edit-indirect-region begin end 'display-buffer)))

I've tested with:

env GUIX_PACKAGE_PATH= ~/src/guix/pre-inst-env\
    guix environment -C --no-grafts\
    --ad-hoc emacs emacs-edit-indirect\
    -l guix.scm

TERM=xterm emacs -nw guix.scm
alezost commented 6 years ago

Does texinfo-mode works for you?

Yes, it works for me. I have not checked your recipe yet, but I bet this problem relates to lexical-binding and byte-compilation. Do you have "guix-devel.elc" file? If so, try to remove it and see if it "fixes" this problem.

alezost commented 6 years ago

@wigust, do you have this problem if you remove guix-devel.elc?

I think this problem shows up just because guix-devel.el is compiled without edit-indirect. So it probably shouldn't appear for MELPA users, since edit-indirect is available there, and it wouldn't appear for the Guix users: when the emacs-guix Guix package will be updated for the next Emacs-Guix release, the package recipe should specify --with-editindirect-lispdir configure option (added by commit 62a50ea1bae7e90a622e9722269ebe449e01145a).

wigust commented 6 years ago

the package recipe should specify --with-editindirect-lispdir configure option (added by commit 62a50ea)

This solves the issue for me as a Guix user. Thank you!