Git Product home page Git Product logo

Comments (3)

Lenbok avatar Lenbok commented on September 15, 2024 1

In your config, before where you define the keymap containing c-g, put something like this:

def clear_mark_or(combo):
    if isinstance(combo, Key):
        combo = Combo(None, combo)

    def _clear_mark_or():
        if transform._mark_set:
            transform._mark_set = False
        else:
            return combo

    return _clear_mark_or

Now in the keymap define c-g like this:

    K("C-g"): clear_mark_or(K("esc")),

It seems to work as your first request (although like M-w, the selection is still visible until you subsequently move).

(edit: btw, I pretty much just copy-pasta'd that from the functions in transform.py)

from xkeysnail.

haji-ali avatar haji-ali commented on September 15, 2024

Brilliant!!

I changed your code to return K("right") when the mark is reset. This becomes almost identical to Emacs behaviour, except for the fact that the cursor is always to the right of the selection even when the point should be to the left. I would have to somehow return K("left") when the "mark" is to the right of the "point" and K("right") otherwise, but I am not sure how to accomplish this.

This is also related to another thing that I wish I could change. In Emacs when C-SPC is pressed on an active selection, the previous selection is undone and the "mark" is at the "point". This would be easy to accomplish if I could figure out where the "point" is by sending the appropriate "left" or "right" keys.

from xkeysnail.

joshgoebel avatar joshgoebel commented on September 15, 2024

What is this "selection" or "point" that you're referring to? All we know is what keys you hit - we know nothing about what you're editing, what is selected, where your cursor is or isn't at... so it's impossible to make decision based on such info.

from xkeysnail.

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.