emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: visual-region-mode?


From: Drew Adams
Subject: RE: visual-region-mode?
Date: Wed, 12 Sep 2018 20:40:30 +0000 (UTC)

> > That I move around in a file as I see fit while reading or editing it
> > doesn't have anything to do with regions I might select to do something
> > with.  I might highlight a selection to make parts of source code stick
> > out as a reminder because they need to be fixed or worked upon in some
> > particular order.  I could use registers and/or bookmarks instead, but
> > it would be much more convenient to use highlighting and perhaps to be
> > able to jump through the selections.

With Bookmark+ you can use (temporary or persistent) bookmarks,
and they can highlight their locations in various ways. You can also
bookmark a region and have it activated when you later jump to it.
You can navigate among the bookmarks in various ways, including
cycling. You can create bookmarks without bothering to name them -
automatic naming based on a template (e.g. with buffer position).

With library `zones.el' you can define a list of multiple regions
(zones) in the same buffer or in a mix of buffers. You can cycle
among them, activating each in turn. You can move among them
as multiple narrowings. You can highlight and unhighlight them.
You can persist them as bookmarks.

> It's probably feasible to add a "type" field to the mark, indicating
> where it came from (i.e., if it was set explicitly by the user, by a
> certain command, from a mouse selection, ...).  Then we could offer
> commands that jump between previous selections, or between previous
> marks set by the user for navigation.

A zone has a start and end (like a region). It can also have an ID.
It can also have any Lisp values as additional data.

> > As for doing other things, like replacing text in multiple parts of a
> > buffer, is that something that could be usefully done with indirect
> > buffers?  With multiple regions, I'd highlight some parts of the buffer,
> > do the replacement limited to these parts and would be done with it.
> > I'd be able to see all of the buffer while doing this.
> 
> Not possible yet, I think (at least, without making N indirect buffers
> for the N regions and running the replacement command in all of them).
> But if we had some way to record the "type" of a previous mark (as
> above), then we could offer a command to replace, for example, the
> last N "active regions" in the buffer.  I think that might fit the
> bill.

You can add the region to a current list of zones (`C-x n a'). Then cycle
among them, activating each in turn (`C-x n r'); and do query-replace or
other actions on each one.

> > Indirect buffers still hold all of the text, so instead of marking what
> > I want to work with, I'd have to narrow out what I'm not working with,
> > and IIRC, it's not possible to narrow a buffer "the other way round" so
> > that the parts I want to work with remain and all the rest of the buffer
> > is narrowed away.
> 
> I don't think that's possible yet.

You can make a list of zones that is the complement of another list
of zones. 

If you also use library `isearch-prop.el' then you can make a list of
zones or its complement invisible, you can search the zones or their
complement. You can add text properties to the zones. When
searching you can dim the complement of the zones being searched,
and you can toggle to search the complement instead (and dim the
original zones).

----

https://www.emacswiki.org/emacs/download/zones.el

https://www.emacswiki.org/emacs/download/isearch-prop.el

https://www.emacswiki.org/emacs/BookmarkPlus



reply via email to

[Prev in Thread] Current Thread [Next in Thread]