GithubHelp home page GithubHelp logo

Comments (19)

marijnh avatar marijnh commented on July 26, 2024

How are you marking them, and what did you expect to happen? Do mark commands still work? As in, it is just that the marked region isn't highlighted, or that you can't mark at all?

from tern.

jxs avatar jxs commented on July 26, 2024

i am marking them with shift and arrows , and mark commands such as mark-word or mark-sexp work, although with arrows i can't mark at all messages buffer outputs :
+1: Mark set
Quit

from tern.

marijnh avatar marijnh commented on July 26, 2024

I've never done shift-arrow selection in emacs, not does it work in a vanilla setup. Which setting/minor-mode are you using to get that?

from tern.

magnars avatar magnars commented on July 26, 2024

I had a similar problem yesterday, but that was using normal C-SPC to set mark. Once the marked region moved over some specific part of the buffer, the mark vanished.

I had no idea what was happening, but next time I'll make sure to disable tern and see if that solves the issue.

from tern.

marijnh avatar marijnh commented on July 26, 2024

The emacs API is unfortunately full of subtle side effects. It's very possible that Tern's post-command-hook is causing this. If you can give me a way to reproduce, I'll try to figure out why.

from tern.

magnars avatar magnars commented on July 26, 2024

If I should wager a guess, it would be with-current-buffer in tern-run-query that messes with the mark. I've seen similar issues with with-temp-buffer at least. I'll let you know if I can reproduce it.

from tern.

jxs avatar jxs commented on July 26, 2024

@marijnh it does come in my vanilla setup, version 24.3
http://www.gnu.org/software/emacs/manual/html_node/emacs/Shift-Selection.html
you can reproduce it by loading any javascript file, loading js2-mode and for example do set-mark and mark a word inside parenthesis, or even parenthesis alone like a function call: foo() or foo(bar)

from tern.

magnars avatar magnars commented on July 26, 2024

Yes, quite right. Just set-mark and move point over a function call. Once the type hints pop up, the mark is deactivated.

from tern.

marijnh avatar marijnh commented on July 26, 2024

If I turn on shift-select-mode (or try to reproduce this by setting the mark with C-space), I still don't see this. Whether I start outside of a call, and go inside it, or start inside and go outside, or just move around inside of the call, the mark stays where it used to be. This is Emacs version 24.1.1.

from tern.

magnars avatar magnars commented on July 26, 2024

I'm on Emacs 24.3.1.

Here's a reproduction:

  • create a file under a directory with a .tern-project that has the browser libs.
  • type in document.appendChild("abc")
  • if you set the mark and move about, everything works fine. This is because the lookup happened when you typed it in.
  • so, go to point 1, save the file, kill the buffer, and reopen it.
  • set the mark, move forward one char at a time until you reach (
  • moving the cursor one more, inside the (, will disable the mark
  • this coincides with the lookup of the function signature - the first time.

Doing it again, won't trigger the bug.

However, I have been able to get it triggering every time. Maybe this has
to do with it not finding the function, and so it keeps looking it up.

from tern.

marijnh avatar marijnh commented on July 26, 2024

Thanks for the detailed instructions. However, for me, this really doesn't happen. Most likely it's a difference between 24.1 and 24.3. I'll try to upgrade.

from tern.

marijnh avatar marijnh commented on July 26, 2024

Unfortunately, no, on 24.3.1 it still isn't happening for me. Very odd.

from tern.

magnars avatar magnars commented on July 26, 2024

That is weird. It is definitely tern. Here's an ascii-cast with emacs -Q reproducing it:

http://ascii.io/a/2956

from tern.

marijnh avatar marijnh commented on July 26, 2024

Using your code (conveniently copy-pasted from the asciicast) I can reproduce the problem. I've reduced it to the http request. Simply calling url-http appears to have the side effect of setting the mark (*Messages* shows a 'Mark set' message at this point). I haven't been able to figure out why -- there are no calls to set-mark or similar in the source of the url-http module.

I suspect this can be solved by shadowing the right dynamic variables. I haven't figured out which one to shadow yet, though.

from tern.

magnars avatar magnars commented on July 26, 2024

Yes, you're probably right about the shadowing. Have you tried save-excursion tho?

from tern.

marijnh avatar marijnh commented on July 26, 2024

Hadn't tried, but it appears save-excursion also doesn't help.

from tern.

marijnh avatar marijnh commented on July 26, 2024

My previous analysis was off, it's not url-http but json-encode that causing this, and it is causing it by calling insert inside a temp buffer. I still haven't found a way to prevent this side effect, and I'm more or less tired of looking. Here's a simple way to reproduce it, if you feel like digging deeper:

(defun shift-selection-disruptor ()
  (interactive)
  (with-temp-buffer
    (insert "x")))

Shift-select something, do M-x, and run shift-selection-disruptor. The selection will be cleared by the insert command.

from tern.

magnars avatar magnars commented on July 26, 2024

Here you go:

(defun shift-selection-disruptor ()
  (interactive)
  (let (deactivate-mark)
    (with-temp-buffer
      (insert "x"))))

from tern.

marijnh avatar marijnh commented on July 26, 2024

Great! See attached patch.

from tern.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.