[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Hard to switch from vi
From: |
Jeremy Hankins |
Subject: |
Re: Hard to switch from vi |
Date: |
Mon, 09 Oct 2006 13:49:52 -0400 |
User-agent: |
Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.50 (gnu/linux) |
Lennart Borgman <lennart.borgman.073@student.lu.se> writes:
> Jeremy Hankins wrote:
>> I personally consider viper to be more of an implementation of vi in
>> elisp; it generally works quite well with other emacs modes without
>> interfering with their use. There are a few exceptions, though -- I'd
>> love to get viper to work better with folding.el, for example.
>
> What version of Emacs do you use? What are the problems with folding.el?
It's the debian unstable emacs-snapshot package 20061003-1, so 22. I'm
using folding.el v3.35, which is current, I believe. I've hacked
folding.el a bit -- mainly to set up an option to not narrow when
folding-shift-in is called. I've attached a patch against folding.el,
if you're interested, and I'm using this advice for viper-search:
;; This advises viper-search so that it behaves well with folding-mode.
(defadvice viper-search (around jjh/folding-viper-search activate)
(let ((executing-kbd-macro t))
ad-do-it)
(let* ((start (match-beginning 0))
(end (match-end 0))
(match (buffer-substring start end)))
(when folding-mode
(folding-shift-in))
(search-forward match end t nil)
(goto-char start))
(or executing-kbd-macro
(memq viper-intermediate-command
'(viper-repeat viper-digit-argument viper-command-argument))
(viper-flash-search-pattern))
ad-return-value)
It's a bit ugly, because it sets executing-kbd-macro so that it can
override the way viper-flash-search-pattern is called. Unfortunately
this disables the message about the search wrapping the buffer, but
without it folding marks are flashed instead of the search match. If
anyone has a better suggestion I'd be interested -- I'm pretty new to
elisp. Ideal would be a hook in viper-search, I guess.
What I'd really like, though, is for ex-style line addressing to work
properly, but I don't really see how that's possible without significant
modifications to viper. From what I can see it looks like viper handles
generating addresses for lines in a variety of places, and they'd all
have to be tracked down to make it behave with folding-mode.
--- folding.el-orig 2006-09-29 16:58:26.000000000 -0400
+++ folding.el 2006-10-04 08:55:59.000000000 -0400
@@ -2004,7 +2004,9 @@
(folding-point-folded-p goal))
(folding-shift-in t))
(goto-char goal)))
- (folding-narrow-to-region (point-min) (point-max) t)))
+ (folding-narrow-to-region
+ (and folding-narrow-by-default (point-min))
+ (point-max) t)))
(if (or folding-stack (folding-point-folded-p (point)))
(folding-open-buffer))))))))
@@ -2114,6 +2116,10 @@
;;; ........................................................ &v-Config ...
+(defvar folding-narrow-by-default t
+ "If t (default) things like isearch will enter folds. If nil the
+folds will be opened, but not entered.")
+
;; Q: should this inherit mouse-yank-at-point's value? maybe not.
(defvar folding-mouse-yank-at-point t
"If non-nil, mouse activities are done at point instead of 'mouse cursor'.
@@ -3604,22 +3610,26 @@
many folds as necessary are entered to make the surrounding text
visible. This is useful after some commands eg., search commands."
(interactive)
- (let ((goal (point)))
- (if (folding-skip-ellipsis-backward)
- (while (prog2 (beginning-of-line)
- (folding-shift-in t)
- (goto-char goal)))
- (let ((data (folding-show-current-entry noerror t)))
- (and data
- (progn
- (setq folding-stack
- (if folding-stack
- (cons (cons (point-min-marker) (point-max-marker))
- folding-stack)
- '(folded)))
- (folding-set-mode-line)
- (folding-narrow-to-region (car data) (nth 1 data))
- (nth 2 data)))))))
+ (labels
+ ((open-fold nil
+ (let ((data (folding-show-current-entry noerror t)))
+ (and data
+ (progn
+ (when folding-narrow-by-default
+ (setq folding-stack
+ (if folding-stack
+ (cons (cons (point-min-marker)
(point-max-marker))
+ folding-stack)
+ '(folded)))
+ (folding-set-mode-line))
+ (folding-narrow-to-region (car data) (nth 1
data)))))))
+ (let ((goal (point)))
+ (while (folding-skip-ellipsis-backward)
+ (beginning-of-line)
+ (open-fold)
+ (goto-char goal))
+ (when (not folding-narrow-by-default)
+ (widen)))))
;;}}}
;;{{{ folding-shift-out
@@ -3764,9 +3774,11 @@
(re-search-forward "[\n\C-m]" nil 0 (1- line)))
(let ((goal (point)))
(while (prog2 (beginning-of-line)
- (folding-shift-in t)
- (goto-char goal))))
- (folding-narrow-to-region (point-min) (point-max) t))
+ (folding-shift-in t)
+ (goto-char goal))))
+ (folding-narrow-to-region
+ (and folding-narrow-by-default (point-min))
+ (point-max) t))
;;}}}
--
Jeremy Hankins <nowan@nowan.org>
PGP fingerprint: 748F 4D16 538E 75D6 8333 9E10 D212 B5ED 37D0 0A03
- Hard to switch from vi, Wen Weng, 2006/10/08
- Re: Hard to switch from vi, Ignacio Mondino, 2006/10/08
- Message not available
- Re: Hard to switch from vi, Hadron Quark, 2006/10/10
- Re: Hard to switch from vi, Jeremy Hankins, 2006/10/10
- Re: Hard to switch from vi, Pascal Bourguignon, 2006/10/10
- Re: Hard to switch from vi, Hadron Quark, 2006/10/13
Message not available
Message not available
Re: Hard to switch from vi, Pascal Bourguignon, 2006/10/08