Git Product home page Git Product logo

mark-multiple.el's Introduction




Please note! mark-multiple has been superseded by multiple-cursors

It has all the functionality of mark-multiple, but with a more robust implementation and more features.

To get the features from mark-multiple, use:

  • mc/mark-more-like-this in place of mark-more-like-this
  • set-rectangular-region-anchor as a more convenient replacement for inline-string-rectangle
  • or mc/edit-lines for a more familiar replacement for inline-string-rectangle
  • mc/mark-sgml-tag-pair in place of rename-sgml-tag

Read more about multiple-cursors on its own page.




mark-multiple.el

An emacs extension that sorta lets you mark several regions at once.

More precisely, it allows for one master region, with several mirror regions. The mirrors are updated inline while you type. This allows for some awesome functionality. Or at least, some more visually pleasing insert and replace operations.

Video

You can watch an intro to mark-multiple at Emacs Rocks.

Done

  • A general library for managing master and mirrors
  • mark-more-like-this which selects next/previous substring in the buffer that matches the current region.
  • inline-string-rectangle which works like string-rectangle but lets you write inline - making it less error prone.
  • rename-sgml-tag which updates the matching tag while typing.

Note: js2-rename-var has been moved to js2-refactor.el.

Installation

git submodule add https://github.com/magnars/mark-multiple.el.git site-lisp/mark-multiple

Then add the modules you want to your init-file:

(require 'inline-string-rectangle)
(global-set-key (kbd "C-x r t") 'inline-string-rectangle)

(require 'mark-more-like-this)
(global-set-key (kbd "C-<") 'mark-previous-like-this)
(global-set-key (kbd "C->") 'mark-next-like-this)
(global-set-key (kbd "C-M-m") 'mark-more-like-this) ; like the other two, but takes an argument (negative is previous)
(global-set-key (kbd "C-*") 'mark-all-like-this)

(add-hook 'sgml-mode-hook
          (lambda ()
            (require 'rename-sgml-tag)
            (define-key sgml-mode-map (kbd "C-c C-r") 'rename-sgml-tag)))

Feel free to come up with your own keybindings.

Bugs and gotchas

  • Adding a master and mirrors does not remove the active region. This might feel strange, but turns out to be practical.

  • The current mark-multiple general library lets you do stupid shit, like adding overlapping mirrors. That's only a problem for people who want to write their own functions using mm/create-master and mm/add-mirror.

  • Seems like there is some conflict with undo-tree.el, which sometimes clobbers the undo history. I might be doing something particularly stupid. Looking into it.

  • Reverting a buffer with active marks makes them unremovable.

A wild idea

Is this a subset of a crazy multiple-point module? Would that even work?

Edit: Yes, indeed it is. And yes, it does. This module has been pretty much eclipsed by multiple-cursors.el, which goes quite a bit farther and with a saner implementation to boot.

Contribute

If you make some nice commands with mark-multiple, it would be great if you opened a pull-request. The repo is at:

https://github.com/magnars/mark-multiple.el

Contributors

  • Pao-Chin Wu fixed mark-next-like-this if no region is active.
  • Syohei YOSHIDA improved the error messages for mark-next-like-this
  • Mounier Florian added mark-all-like-this and mark-all-like-this-in-region

Thanks!

License

Copyright (C) 2011 Magnar Sveen

Author: Magnar Sveen [email protected] Keywords: marking library

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

mark-multiple.el's People

Contributors

magnars avatar paradoxxxzero avatar syohex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mark-multiple.el's Issues

Invalid read syntax: "?"

emacs 24 (on windows 7) complains about these 2 lines:

((or (eq base 'up) (eq base ?ĂĽ))

and

((or (eq base 'down) (eq base ?ĂŚ))

in mark-more-like-this.el throwing a message: Invalid read syntax: "?"

Missing Version string.

It would probably be good to either have mark-multiple-pkg.el file in the package or to add a Version: string to the head of mark-multiple.el.

js2-rename-vars is missing

Hi @magnars ! First of all, thanks for utterly useful emacs mode and great videos on Emacs Rocks!

Now, I know that I may just talk rubbish, but I can't find js2-rename-var in mark-multiple. What's the catch?

Something about mark-multiple.el

I am new to emacs and elisp but enjoying looking for useful emacs plugins like mark-multiple. I have some questions about mark-multiple:

1.Skip some next/previous substrings like:

abc
abc-config
abc

How can I skip the second 'abc' but mark the first and third 'abc' ?

2.Sometimes the text is to long, if marking previous/next can scroll the screen at the same time that will be awesome.

3.Sometimes I press 'C->' too fast and want to cancel marking some, how can I do that ?

I am new to elisp and confused by the document string. So I hope I can find an answer here.
If some of these are not provided in the current version I will be glad to see them in the next release. :)

mark-multiple could initialize from isearch

Here's an idea: one common workflow is to 1. isearch for a work, 2. start query-replace from within isearch. (It is so common to invoke query-replace from isearch that the Emacs maintainer once commented to me that this could be the only way.)

I've extended isearch slightly in order to be able to kill the current match from within isearch and keep isearch'ing:

;; Often during incremental search I want to delete the search match.  This                                                                                                                                                                                                       
;; binds the C-k key in isearch mode to to just that.                                                                                                                                                                                                                             
(defun kill-isearch-match ()
  "Kill the current isearch match string and continue searching."
  (interactive)
  (kill-region isearch-other-end (point)))

(define-key isearch-mode-map [(control k)] 'kill-isearch-match)

It would be great if mark-multiple would support being invoked from isearch.

(This is of course just an idea, I suppose I could hook this up myself, but since this is recent development, I thought you might find it interesting. I currently 1. isearch to the work I want to replace, 2. exit isearch, 3. reselect the word for mark-multiple, 4. invoke mark-multiple. It's a bit much.)

Cheers,

Other places don't change color

if you have few cursors and each should trigger higlight change the color is changed only to the first one.
Example:

you have (in web-mode) php tags (inside strings) and want to change it to twig/django tags.

<li><a href="<?= $item['href'] ?>"><?= $item['name'] ?></a></li>
<li><a href="<?= $item['href'] ?>"><?= $item['name'] ?></a></li>
<li><a href="<?= $item['href'] ?>"><?= $item['name'] ?></a></li>

in web mode it's white (I think broken) and if you change that to {{ and }} using multiply cursors

<li><a href="{{ item['href'] }}">{{ item['name'] }}</a></li>
<li><a href="{{ item['href'] }}">{{ item['name'] }}</a></li>
<li><a href="{{ item['href'] }}">{{ item['name'] }}</a></li>

only first instance will get color. They all should have changed.

Maybe it's something with web-mode.

move cursor and view to next selection

When mark-next-like-this is called I would like the cursor and current buffer to scroll to the end of the last item marked.

I've tried to modify mark-next-like-this as such:

L69       (if (search-forward master-str nil t)
                (progn
                  (set-window-point (get-buffer-window (current-buffer) 'visible) (point))
                  (mm/add-mirror (- (point) (length master-str)) (point))
                )

I've also tried to use (goto-point (point)) instead but neither seem to do anything at all, do you have any idea how I could implement that?

packaging?

Is it possible (and practical) to make this an installable package?

Breaks Pabbrev

Hi, great mode, however there's an issue when it is used with Pabbrev, pabbrev shows autocompetion candidates directly into the buffer which mess up the text when used with a multi-mark (tried with C-x r t & C->/<).

You should be able to test pretty easily:
(require 'pabbrev)
(global-pabbrev-mode)
(setq pabbrev-idle-timer-verbose nil)

Then try to use a multi-mark command...

I think pabbrev is bundled with the Emacs 23/24 -- not sure.

A simple fix would be to toggle pabbrev on/off when entering mark mode, maybe they already are some hooks I can use for that... I would have checked/fixed myself but my elisp is "hack 'till it works" level, I'm sure you can find a cleaner solution than what I could come up with.

Mark multiple and auto-complete do not mingle well in ESS's R-mode

mark-multiple mc/mark-next-like-this does not mark the next occurrence correctly.

In a R-mode buffer, if I have

## TH 1
abcd
## TH 2
efg
## TH 3

I select the first TH and then mark-next-like-this to select the second TH. After that I repeat the command and it selects the abcd line.

I have auto-complete enabled for R. When I disable auto-comlpete-mode, it works correctly. A work-around would be to disable auto-complete-mode before running mc/mark-next-like-this for example:

(defadvice mc/mark-next-like-this (around fix-issue)
  (let ((ac-on (and (boundp 'auto-complete-mode) auto-complete-mode)))
    (when ac-on
      (auto-complete-mode -1))
    ad-do-it
    (when ac-on
      (auto-complete-mode 1))))

However this still doesn't work for me.

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.