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

guix-devel-mode's function fail on package ending with "+" #24

Closed Ambrevar closed 6 years ago

Ambrevar commented 6 years ago

On emacs-image+, C-c . b tries to run

,run-in-store (build-package emacs-image #:use-substitutes? #t #:dry-run? #f)

The + is missing. The command works if I add the + manually.

alezost commented 6 years ago

I don't reproduce: it uses the full symbol for me (with the + character). Maybe the point was placed before emacs-image+ definition (on the first open parenthesis?) I guess the previous definition has emacs-image name.

Could you check M-: (guix-guile-current-definition) on that emacs-image+ definition? Note, the point should be placed somewhere inside this expression:

(define-public emacs-image+
  ;;...
  )

(Not on the first open parenthesis!)

Ambrevar commented 6 years ago

I can reproduce with the point inside the definition: (guix-guile-current-definition) returns emacs-image.

alezost commented 6 years ago

Hm, strange, perhaps, the buffer you call it from have an unusual syntax table, so guix-guile-definition-regexp variable can't handle it. Do you run this command from scheme-mode buffer? Did you maybe modify `scheme-mode-syntax-table'?

Ambrevar commented 6 years ago

I did not. Here is the list of the active modes in my emacs.scm buffer:

Enabled minor modes: Async-Bytecomp-Package Auto-Composition Auto-Compression
Auto-Encryption Auto-Revert Cl-Old-Struct-Compat Column-Number Company
Desktop-Save Diff-Auto-Refine Dired-Async Display-Line-Numbers Eldoc
Electric-Indent Evil Evil-Local File-Name-Shadow Fish-Completion Font-Lock
Geiser Geiser-Autodoc Global-Eldoc Global-Fish-Completion Global-Font-Lock
Global-Git-Commit Global-Magit-File Global-Undo-Tree Guix-Devel Helm
Helm-Descbinds Helm-Top-Poll Lispyville Magit-Auto-Revert Magit-File Mouse-Wheel
Pdf-Occur-Global Rainbow-Delimiters Recentf Save-Place Savehist Shell-Dirtrack
Show-Paren Size-Indication Tooltip Transient-Mark Undo-Tree Which-Key
Window-Divider
Ambrevar commented 6 years ago

And here is the full definition, in case that matters:

(define-public emacs-image+
  (package
    (name "emacs-image+")
    (version "20150707.916")
    (source
     (origin
       (method url-fetch)
       (uri (string-append
             "https://melpa.org/packages/image+-"
             version
             ".el"))
       (sha256
        (base32
         "0lbgqc9n2ard9nrsk9ri2jazk8l6dv2hrmi83dvsm14kfnnajdil"))))
    (build-system emacs-build-system)
    (propagated-inputs `(("imagemagick" ,imagemagick)))
    (home-page
     "https://github.com/mhayashi1120/Emacs-imagex")
    (synopsis
     "Image manipulate extensions for Emacs")
    (description
     "Type @code{C-x C-l +} to zoom-in the current image.
You can zoom-out with type @code{-}.
To manipulate a image under cursor: @code{M-x imagex-sticky-mode}.
Or to activate globally: @code{M-x imagex-global-sticky-mode}.
Or in .emacs: @code{(eval-after-load 'image+ '(imagex-global-sticky-mode 1))}.

- @code{C-c +} / `C-c -`: Zoom in/out image.
- @code{C-c M-m}: Adjust image to current frame size.
- @code{C-c C-x C-s}: Save current image.
- @code{C-c M-r} / @code{C-c M-l}: Rotate image.
- @code{C-c M-o}: Show image @code{image+} have not modified.

Adjusted image when open image file: @code{M-x imagex-auto-adjust-mode}.
Or in .emacs: @code{(eval-after-load 'image+ '(imagex-auto-adjust-mode 1))}.
If you do not want error message in minibuffer: @code{(setq imagex-quiet-error t)}.")
    (license license:gpl3+)))
alezost commented 6 years ago

Could you evaluate (with M-: for example) the following expression:

(re-search-forward "\\(?:[[:word:]]\\|\\s_\\)+" nil t)

Does it stop after or before + character?

Ambrevar commented 6 years ago

When the point is anywhere before the +, the above search stops at the +.

alezost commented 6 years ago

OK, this is the culprit: for me, the point stops right after +.

Could you also check (when the point is on image+ word):

(re-search-forward "\\s_" nil t)

For me, it also stops after + .

Ambrevar commented 6 years ago

With the point on the i in (define-public emacs-image+, your last search moves on to the i in `(name "emacs-image+").

alezost commented 6 years ago

Could you test it when the point is on i in image+ word?

Ambrevar commented 6 years ago

Which image+ word? You mean if I remove the emacs- prefix? Then same thing.

alezost commented 6 years ago

No, I mean when my point is placed on i letter in emacs-image+ and I eval (re-search-forward "\\s_" nil t), the point is moved right after +. Is it the same for you?

Ambrevar commented 6 years ago

No, that's the test I mentioned before (I meant the i in emacs-image+, not in define-public, sorry for the confusion).

alezost commented 6 years ago

OK, it means that + is not counted as a "symbol" syntax character for you. I have just found M-x describe-syntax command. When I call it from .scm buffer, I see the following line there:

* .. +          _   which means: symbol

I.e. + sign is counted as "symbol" on my side.

Maybe there is some difference in our Emacs versions (I use 25.3.1), or some third-party package modifies syntax table. Oh, btw could you make a test with "emacs -Q"? I mean just open some buffer in scheme-mode, write foo+ there, and check if M-: (re-search-forward "\\s_" nil t) moves the point after + or not.

Ambrevar commented 6 years ago

You are right, my syntax table has changed:

+ .. ,                  '   which means: prefix

I use Emacs 26 and there is no issue with emacs -Q.

I suspect lispy to be the culprit. I'll investigate further.

alezost commented 6 years ago

OK, please let me know if you find out what "evil" package does it :-)

I am closing this issue.

Ambrevar commented 6 years ago

I found the root of the issue: it's in guix/.dir-locals.el (official file):

   ;; This notably allows '(' in Paredit to not insert a space when the
   ;; preceding symbol is one of these.
   (eval . (modify-syntax-entry ?~ "'"))
   (eval . (modify-syntax-entry ?$ "'"))
   (eval . (modify-syntax-entry ?+ "'"))

I'm not sure to understand the comment. What do you think? Should emacs-guix adapt to this or should we discuss this behaviour upstream?

alezost commented 6 years ago

I found the root of the issue: it's in guix/.dir-locals.el (official file):

Good to know, thank you for investigating!

I'm not sure to understand the comment. What do you think?

I have no idea how it effects Paredit behaviour.

Should emacs-guix adapt to this or should we discuss this behaviour upstream?

It's not a problem to adjust the regexp in Emacs-Guix, but I think .dir-locals shouldn't do it. I believe (re-search-forward "\\s_" nil t) should find + character in lisp/scheme modes. Even elisp manual mentions that $&*+-_<> characters may be part of a symbol name in Lisp mode:

https://www.gnu.org/software/emacs/manual/html_node/elisp/Syntax-Class-Table.html#Syntax-Class-Table

So my opinion is that this should be fixed on the Guix side.

Ambrevar commented 6 years ago

I've reported the issue on guix-devel.

alezost commented 6 years ago

I see, thanks!