Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Ambrevar opened this issue May 18, 2018 · 20 comments
Closed

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

Ambrevar opened this issue May 18, 2018 · 20 comments

Comments

@Ambrevar
Copy link

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
Copy link
Owner

alezost commented May 19, 2018

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
Copy link
Author

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

@alezost
Copy link
Owner

alezost commented May 19, 2018

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
Copy link
Author

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
Copy link
Author

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
Copy link
Owner

alezost commented May 19, 2018

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
Copy link
Author

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

@alezost
Copy link
Owner

alezost commented May 19, 2018

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
Copy link
Author

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

@alezost
Copy link
Owner

alezost commented May 19, 2018

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

@Ambrevar
Copy link
Author

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

@alezost
Copy link
Owner

alezost commented May 19, 2018

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
Copy link
Author

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

@alezost
Copy link
Owner

alezost commented May 19, 2018

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
Copy link
Author

Ambrevar commented May 19, 2018 via email

@alezost
Copy link
Owner

alezost commented May 19, 2018

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

I am closing this issue.

@alezost alezost closed this as completed May 19, 2018
alezost added a commit that referenced this issue May 19, 2018
Reported by Pierre Neidhardt:
<#24>.  Well, it was not really
the issue but it is better to define the definition from its start
position, anyway.

* elisp/guix-guile.el (guix-guile-current-definition): Define the
current definition properly when the point is in the beginning of it.
@Ambrevar
Copy link
Author

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
Copy link
Owner

alezost commented May 20, 2018

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
Copy link
Author

Ambrevar commented May 20, 2018 via email

@alezost
Copy link
Owner

alezost commented May 21, 2018

I see, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants