Russell Dunphy | 14 Sep 00:17 2014

Evil-mode defining ex commands & redefining whole line commands (eg. dd)

Hi, new to Emacs (Evil-mode persuading me that it’s worth attempting the switch). Have a few questions.

I’m trying to get adhoc key mappings working as they would in vim. So for example if I open a new Clojure file I might want to quickly set up a mapping to run it. In vim this would be something like:

:map ,t :!lein exec %<CR>

Is there a way to implement the `map` ex command in evil-mode to make creating arbitrary, temporary mappings like this possible and easy?

Second question relates to trying to get evil-mode to play nicely with paredit. I’m using `evil-paredit-mode` which makes most things work, but whole line commands such as `dd` don’t seem to work, and I can’t work out how to rebind them. I’ve tried the following:

(evil-define-key 'normal evil-paredit-mode-map (kbd “dd”)
  (lambda () (move-beginning-of-line)
             (evil-paredit-delete-line))

But I get the error “key sequence dd starts with non-prefix key d”.

Thanks in advance for your help!

Russell
_______________________________________________
implementations-list mailing list
implementations-list <at> lists.ourproject.org
https://lists.ourproject.org/cgi-bin/mailman/listinfo/implementations-list
Gabriel Barta | 11 Sep 05:14 2014
Picon

evil-noautochdir : keeping the working directory the same as you work

Hi,

I disliked the emacs behaviour where the current directory would always be the
one containing the current file. So I wrote a bit of elisp to change it, named
according to the equivalent setting in Vim.  It actually leaves the emacs
behaviour unchanged for compatibility with vanilla Emacs packages, and instead
redirects evil to work with a different variable for the current directory. I
originally had something that controlled the emacs default-directory variable
instead, but the current approach gives a smoother experience.

I'd love to hear your feedback. The repo can be found at
https://github.com/gbarta/evil-noautochdir

I think it would be great to have this as part of Evil, but I am not sure if
anyone else is interested in this aspect of compatibility with Vim.  If you
are, let me know!
Albert Krewinkel | 8 Sep 21:56 2014
Picon

Problem with parent keymap

Hi,

I just encountered some unexpected behavior when defining key bindings
for maps which have parent maps:  When I define a key for some state for
the parent map as well as the child map, the child map overrides the
bindings for the parent map.

Here is what I mean:

    (defun alok-foo () (interactive) (message "foo"))
    (defun alok-bar () (interactive) (message "bar"))

    (defvar alok-mode-map (make-sparse-keymap))
    (defvar alok-child-mode-map
      (let ((map (make-sparse-keymap)))
        (set-keymap-parent map alok-mode-map)
        (define-key map (kbd "M-<return>") 'alok-bar)
        map))

    (define-derived-mode alok-mode prog-mode "ALOK"
      "Major ALOK mode")
    (define-derived-mode alok-child-mode alok-mode "calok"
      "ALOK derived mode")

    (evil-set-initial-state 'alok-mode 'motion)
    (evil-set-initial-state 'alok-child-mode 'motion)

    (evil-define-key 'motion alok-mode-map
      (kbd "f") 'alok-foo)
    (evil-define-key 'motion alok-child-mode-map
      (kbd "f") 'alok-bar)

When I enter into alok-mode and press `f`, I would ecpect to see "foo"
in the message area, but instead I get "bar".

I tried to find the reason for this myself, but I got stuck quickly.
Is there a way to work around this?

Thanks in advance!

Albert

--

-- 
Albert Krewinkel
GPG: 8eed e3e2 e8c5 6f18 81fe  e836 388d c0b2 1f63 1124
Елена | 2 Sep 06:17 2014
Picon

Есть проблемы с сайтом? Мы поможем!

ТОЛЬКО ДО 15 сентяюря 2014 года!

1. Хостинг и домен в зоне RU на ваше имя на 1 год
2. Наполнение сайта текстом и фото (предоставляется заказчиком)
3. Форма отправки сообщений и карта проезда
4. Красивая фотогалерея
5. Создание 6-8 страниц сайта

Заказать сайт

(812) 981-72-40
(952) 368-65-21

info <at> el-sites.ru

www.el-sites.ru
Skype: el.sites

 

Если Вы хотите отписаться от рассылки, нажмите здесь
_______________________________________________
implementations-list mailing list
implementations-list <at> lists.ourproject.org
https://lists.ourproject.org/cgi-bin/mailman/listinfo/implementations-list
Tad Ashlock | 24 Aug 16:29 2014
Picon

Issues Integrating Other Modes With Evil-Mode

I'm attempting to integrate org-mode with evil-mode.  I'm aware of the existing evil-org-mode, but what I'm attempting is much deeper.  Rather than just adding some evil keybindings to some org functions, I want
 the basic evil operations to work on org files.  That is, evil-mode operators, commands, and motions are org-aware.

I see that when evil-mode is in the normal state:

* the user presses 'x', which is bound to evil-delete-char
* evil-delete-char calls evil-delete
* evil-delete calls Emacs's delete-region to perform the deletion

When my new evil-org-mode (a minor mode) is active, I need evil-delete-char to call org-delete-char to perform the deletion.  Not directly, of course.  The following seems to work.

(defun evil-org-delete-region (beg end)
  (let ((N (- end beg)))
    (save-excursion
      (goto-char beg)
      (org-delete-char N))))

(evil-define-operator evil-org-delete-char (beg end type register)
  "Delete next character."
  :motion evil-forward-char
  (interactive "<R><x>")
  (cl-letf (((symbol-function 'delete-region) #'(lambda (beg end) (evil-org-delete-region beg end))))
    (evil-delete beg end type register)))

(define-key evil-org-mode-map [remap evil-delete-char] #'evil-org-delete-char)

Essentially, I remap evil-delete-char to evil-org-delete-char.  This new function temporarily redefines delete-region to be evil-org-delete-region, which, in turn, calls org-delete-char.  Then the subsequent cal
l to evil-delete will call org-delete-char with no changes to the evil-mode source code.  Great!  But...

(1) This approach gets more complicated for other evil-mode functions.

    * For example, evil-org-delete-backward-char-and-join requires more indirection in order to restore the function-cell value of delete-backward-char, because that's what the org-mode function needs to call.

    * Remapping a remapped binding doesn't chain.  And it appears that remapping a binding in my minor mode doesn't override the remapped binding that evil-mode does.  For example, if I remap delete-backward-cha
r in evil-org-mode, the evil-mode (insert state) binding (evil-delete-backward-char-and-join) still gets called.

    * I can't figure out how to intercept operators like "dd" (delete whole line), in order to override their low-level Emacs calls.

(2) This approach isn't composable.  That is, another minor mode could not integrate with evil-mode while evil-org-mode is active.


Questions:

(1) Is there a good, clean, composable, way of doing what I'm trying to do?

(2) If not, is there an acceptable change that could be made to evil-mode to support what I'm trying to do?  A change that improves the ability to integrate with evil-mode in general, not just for my purpose?

If the answer to question (1) is 'no', I'm thinking the answer to question (2) might be something along the lines of replacing evil-mode's calls to fundamental Emacs text manipulation commands (like delete-regio
n) with (abnormal) hooks.  Each hook would default to being the command currently being called directly, but could be made buffer local and modified by another mode to support awareness of the buffer's contents.
  This would also allow, in theory, multiple modes to hook into the actions.  Although I can't quite picture how this would work cleanly in practice.

Thank you,
--Tad
_______________________________________________
implementations-list mailing list
implementations-list <at> lists.ourproject.org
https://lists.ourproject.org/cgi-bin/mailman/listinfo/implementations-list
Linus Arver | 9 Aug 17:17 2014
Picon

cursor: make underlying letter bold

Hello,

In GVim, when I move my cursor around in normal mode, the letter
underneath the cursor position becomes bolded.

Is there a simple way to do the same thing in Evil? Or, is this is more
of a syntax highlighting issue?

While I'm not a Lisp expert, I can see that my request involves
`evil-set-cursor` in evil-common.el...

-L
Bob Nnamtrop | 30 Jul 18:46 2014
Picon

Include underscore in word

This seems like a trivial question but a lot of searching has not produced an answer. I'm trying to make the change from viper to evil. One thing that surprises me is the underscores are not considered part of a work for various word commands (e.g, w, cw, etc). I tried vim and they are considered part of the word and in viper they are as well. I find the choice in evil strange. Is there a way to make underscores part of words in evil?

Thanks,
Bob
_______________________________________________
implementations-list mailing list
implementations-list <at> lists.ourproject.org
https://lists.ourproject.org/cgi-bin/mailman/listinfo/implementations-list
Linus Arver | 26 Jul 18:56 2014
Picon

visual selection and X primary behavior

Hello all,

In regular Emacs (with Evil mode turned on, of course), I can (1) do
visual selection of a region, and it will automatically copy that
selection into the X primary selection buffer. This way, I can simply do
SHIFT+INSERT in another X program (e.g., Firefox) and I will paste the
selection that way. Conversely, I can (2) SHIFT+INSERT into Emacs/Evil
(in Insert mode), and it will paste whatever is in the X primary buffer.

However, behavior (1) does not work in terminal-mode Emacs (`emacs
-nw`), although behavior (2) works as expected. I have tried to work
around this by using my `"+y` macro which is enabled with

    (define-key evil-normal-state-map ",y" "\"+y")

in my .emacs, but it fails with the message

    After 0 kbd macro iterations: X selection unavailable for this frame

. Is this a bug in Evil or is it something in Emacs itself?

-L
Gulshan Singh | 1 Jul 08:06 2014
Picon

Vim Movement

Hi,

I'm wondering how if it's possible emulate Vim word movement using the same M-f and M-b bindings in Emacs? I've currently done this:

(global-set-key (kbd "M-f") 'evil-forward-word-begin)
(global-set-key (kbd "M-b") 'evil-backward-word-end)

That's decent, but I think that actual Vim movement uses the evil-forward-word-end and evil-backward-word-begin methods as well. How can I do this?
_______________________________________________
implementations-list mailing list
implementations-list <at> lists.ourproject.org
https://lists.ourproject.org/cgi-bin/mailman/listinfo/implementations-list
Johann Klähn | 27 Jun 14:26 2014
Picon

evil: work on support for ]p, [p (adjust indent on paste)

Hi there,
I would like to work on a patch to add support for ]p and [p to evil. I have some working code (see below) to adjust the indent after a call to evil-paste-after / evil-paste-before, but I would appreciate tips on how to integrate this with existing evil code (especially so that ]p will be a single undo step, that evil-paste-pop still works, …).

All the best,
Johann

(defun get-common-indent-in-region (start end)
  (setq end (copy-marker end))
  (unwind-protect
      (let (indentation)
        (save-excursion
          (goto-char start)
          (or (bolp) (forward-line 1))
          (while (< (point) end)
            (skip-chars-forward " \t")
            (setq indentation
                  (cons (current-column) indentation))
            (forward-line 1)))
        (apply #'min indentation))
    (move-marker end nil)))

(defun my-evil-adjust-indent-afer-paste ()
  (interactive)

  (unless (memq last-command
                '(evil-paste-after
                  evil-paste-before))
    (error "Previous command was not a line-wise evil-paste: %s" last-command))

  (let* ((start (evil-get-marker ?\[))
         (end (evil-get-marker ?\]))
         (common (get-common-indent-in-region start end))
         (this
          (save-excursion
            (cond
             ((eq last-command 'evil-paste-before)
              (goto-char end)
              (forward-line 1))
             (t
              (goto-char start)
              (forward-line -1)))
            (skip-chars-forward " \t")
            (current-column))))
    (indent-rigidly start end (- this common))))
_______________________________________________
implementations-list mailing list
implementations-list <at> lists.ourproject.org
https://lists.ourproject.org/cgi-bin/mailman/listinfo/implementations-list
Justin M. Keyes | 7 Jun 09:45 2014
Picon

binding to "cp" without breaking "c"

Hi,

I'm trying to bind a command to the "unused namespace" that happens to
start with "c". By "unused namespace" I mean things like "cp" or "co"
for which there is no valid text object or motion. In Vim, you can
bind "cow" and it does not affect the behavior of "cdw", "ciw", etc,
because "o" is not defined as a text object. For example, in
unimpaired.vim[1], "cow" toggles word-wrap. I would like to do this in
emacs evil, so I tried:

    (define-key evil-normal-state-map (kbd "c o w") 'toggle-truncate-lines)

It reports "eval-region: Key sequence c p w starts with non-prefix key
c". But I don't want to unbind "c" because then I can't use the
evil-change operator.

I tried defining a custom operator, but after looking at the evil
source code I couldn't figure out how to hook into evil-change to
preserve its behavior while listening for "o" and then routing it
somewhere else.

It seems like I'm missing something, I would think this is a common
task, but I haven't found any posts that address this.

Thanks for evil, it's superb!

[1] https://github.com/tpope/vim-unimpaired

Justin M. Keyes

Gmane