all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jeremy Hankins <nowan@nowan.org>
Subject: Re: Hard to switch from vi
Date: Mon, 09 Oct 2006 13:49:52 -0400	[thread overview]
Message-ID: <8764et2xbz.fsf@wasp.nowan.org> (raw)
In-Reply-To: 452A60EB.4040307@student.lu.se

[-- Attachment #1: Type: text/plain, Size: 2141 bytes --]

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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Patch against folding.el --]
[-- Type: text/x-patch, Size: 2699 bytes --]

--- 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))
 
 ;;}}}
 

[-- Attachment #3: Type: text/plain, Size: 106 bytes --]


-- 
Jeremy Hankins <nowan@nowan.org>
PGP fingerprint: 748F 4D16 538E 75D6 8333  9E10 D212 B5ED 37D0 0A03

[-- Attachment #4: Type: text/plain, Size: 152 bytes --]

_______________________________________________
help-gnu-emacs mailing list
help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs

  reply	other threads:[~2006-10-09 17:49 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-08 23:32 Hard to switch from vi Wen Weng
2006-10-09  0:12 ` Ignacio Mondino
2006-10-09  7:10   ` Lennart Borgman
2006-10-09 10:57     ` Jeremy Hankins
2006-10-09 14:47       ` Lennart Borgman
2006-10-09 17:49         ` Jeremy Hankins [this message]
     [not found]     ` <mailman.7914.1160393911.9609.help-gnu-emacs@gnu.org>
2006-10-10 13:03       ` Hadron Quark
2006-10-10 13:50         ` Pascal Bourguignon
2006-10-13 10:36           ` Hadron Quark
2006-10-10 14:11         ` Jeremy Hankins
     [not found]   ` <mailman.7909.1160377822.9609.help-gnu-emacs@gnu.org>
2006-10-10  1:39     ` Wen Weng
     [not found] ` <mailman.7907.1160352764.9609.help-gnu-emacs@gnu.org>
2006-10-09  0:40   ` Wen Weng
2006-10-09  1:48     ` Ajit Mylavarapu
2006-10-09  2:03 ` ext-chunye.wang
2006-10-09  2:09   ` Pascal Bourguignon
2006-10-09  2:44     ` Wen Weng
2006-10-10 12:59       ` Hadron Quark
2006-10-09  2:04 ` Pascal Bourguignon
2006-10-10 11:53   ` Hadron Quark
2006-10-11 13:35   ` martin
2006-10-09  8:52 ` Markus Triska
2006-10-09  8:53   ` David Kastrup
2006-10-09 16:28     ` Harald Hanche-Olsen
2006-10-10  1:36   ` Wen Weng
2006-10-10 11:16     ` Markus Triska
2006-10-10 13:05     ` Hadron Quark
2006-10-10 14:02       ` Pascal Bourguignon
2006-10-10 12:20   ` Hadron Quark
2006-10-10 12:32     ` Pascal Bourguignon
2006-10-10 12:38     ` Markus Triska
2006-10-10 12:57       ` Hadron Quark
2006-10-09 12:01 ` lgfang
2006-10-10  1:17   ` Wen Weng
2006-10-09 13:28 ` Ken Goldman
2006-10-09 15:06   ` Malte Spiess
2006-10-10  7:18   ` Giorgos Keramidas
     [not found] ` <45299CB0.5090003@speakeasy.net>
     [not found]   ` <4529A0E4.60403@charter.net>
2006-10-09  9:58     ` ken
2006-10-10  0:50     ` Stefan Monnier
     [not found]     ` <mailman.7911.1160387922.9609.help-gnu-emacs@gnu.org>
2006-10-10  1:22       ` Wen Weng
2006-10-10  2:23         ` Micha Feigin
2006-10-21 17:25         ` don provan
2006-10-22 19:36           ` Lennart Borgman
     [not found]           ` <mailman.132.1161545823.27805.help-gnu-emacs@gnu.org>
2006-10-23 17:15             ` don provan
2006-10-23 17:53               ` Lennart Borgman
2006-10-23 18:56               ` Floyd L. Davidson
2006-10-24  9:01                 ` Mathias Dahl
2006-10-24 10:12                   ` Floyd L. Davidson
2006-10-24 11:25                     ` Mathias Dahl
2006-10-24 18:23                       ` Floyd L. Davidson
2006-10-25 14:21                         ` Mathias Dahl
2006-10-21 21:00         ` Dieter Wilhelm
2006-10-11 22:21 ` John Sullivan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8764et2xbz.fsf@wasp.nowan.org \
    --to=nowan@nowan.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.