unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* A few questions about occur-mode
@ 2002-09-20 11:44 Juanma Barranquero
  2002-09-21 19:39 ` Richard Stallman
  0 siblings, 1 reply; 14+ messages in thread
From: Juanma Barranquero @ 2002-09-20 11:44 UTC (permalink / raw)


1.- Would anyone object to making some occur functions (namely
`occur-mode-goto-occurrence', `occur-mode-display-occurrence' and
`occur-mode-goto-occurrence-other-window') to accept an optional
argument and do a (recenter arg) after moving the point? My main use of
occur is:

M-x occur "whatever"
C-x o
C-n C-n ... C-o    # see something
C-n C-n ... C-o    # again...

and it's very handy to put that "something" at the beginning of the
window.

2.- Why are the functions called occur-mode-* instead of simply occur-*?

3.- Do `occur-next' and `occur-prev' do something, or are they remnants
of some long-deleted code, a half-implemented idea, or what? AFAICS, the
'occur-point property is only referenced in `occur-next', `occur-prev'
and `sh-mark-line' (in progmodes/sh-script.el).

4.- IMO it'd be nice to have bindings in occur-mode to do C-n C-o and
C-p C-o (I'd put them in M-n, M-p instead of occur-{next|prev}, but
C-M-n and C-M-p would do fine too). Useful, or something to be relegated
to my .emacs? :-)

Thanks,


                                                           /L/e/k/t/u

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: A few questions about occur-mode
  2002-09-20 11:44 A few questions about occur-mode Juanma Barranquero
@ 2002-09-21 19:39 ` Richard Stallman
  2002-09-22 17:32   ` Juanma Barranquero
  0 siblings, 1 reply; 14+ messages in thread
From: Richard Stallman @ 2002-09-21 19:39 UTC (permalink / raw)
  Cc: emacs-devel

    1.- Would anyone object to making some occur functions (namely
    `occur-mode-goto-occurrence', `occur-mode-display-occurrence' and
    `occur-mode-goto-occurrence-other-window') to accept an optional
    argument and do a (recenter arg) after moving the point? My main use of
    occur is:

These functions are part of a series that exist in many different
parts of Emacs (including Dired, for instance).  So the decision
of whether to change them in this way calls for more thought.

For now, please don't.

    4.- IMO it'd be nice to have bindings in occur-mode to do C-n C-o and
    C-p C-o (I'd put them in M-n, M-p instead of occur-{next|prev}, but
    C-M-n and C-M-p would do fine too). Useful, or something to be relegated
    to my .emacs? :-)

If we do this, we should do it in all of those modes.  This too calls for
more though and study.

    2.- Why are the functions called occur-mode-* instead of simply occur-*?

No particular reason.

    3.- Do `occur-next' and `occur-prev' do something, or are they remnants
    of some long-deleted code, a half-implemented idea, or what? AFAICS, the
    'occur-point property is only referenced in `occur-next', `occur-prev'
    and `sh-mark-line' (in progmodes/sh-script.el).

I don't remember anything about that.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: A few questions about occur-mode
  2002-09-21 19:39 ` Richard Stallman
@ 2002-09-22 17:32   ` Juanma Barranquero
  2002-09-22 23:45     ` John Paul Wallington
  2002-09-23  0:16     ` Richard Stallman
  0 siblings, 2 replies; 14+ messages in thread
From: Juanma Barranquero @ 2002-09-22 17:32 UTC (permalink / raw)
  Cc: emacs-devel


On Sat, 21 Sep 2002 15:39:38 -0400
Richard Stallman <rms@gnu.org> wrote:

> For now, please don't.

Ok. Still, it´d be useful to give it some though as you suggest.

> If we do this, we should do it in all of those modes.  This too calls for
> more though and study.

Ok. My .emacs for now, then.

> No particular reason.

Wouldn´t then be logical to rename them? AFAIK, user functions for a
mode FOO are usually FOO-func1, FOO-func2, not FOO-mode-func1,
FOO-mode-func2. I don´t think changing them would cause trouble, as
users are probably using them throug bindings in occur-mode and not
directly with M-x.

> I don't remember anything about that.

Any idea, anyone?

Thanks,

-- 
Juanma Barranquero <lektu@terra.es>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: A few questions about occur-mode
  2002-09-22 17:32   ` Juanma Barranquero
@ 2002-09-22 23:45     ` John Paul Wallington
  2002-09-23 11:04       ` Juanma Barranquero
  2002-09-23 15:59       ` Richard Stallman
  2002-09-23  0:16     ` Richard Stallman
  1 sibling, 2 replies; 14+ messages in thread
From: John Paul Wallington @ 2002-09-22 23:45 UTC (permalink / raw)
  Cc: emacs-devel

Juanma Barranquero <lektu@terra.es> wrote:

>> I don't remember anything about that.
>
> Any idea, anyone?

`occur-next' and `occur-prev' work in the EMACS_21_1_RC branch.

In HEAD they could be changed to use `occur-match' property instead of
`occur-point', or `occur-engine' could add `occur-point' properties to
its output.  Which is better ?

-- 
John Paul Wallington

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: A few questions about occur-mode
  2002-09-22 17:32   ` Juanma Barranquero
  2002-09-22 23:45     ` John Paul Wallington
@ 2002-09-23  0:16     ` Richard Stallman
  1 sibling, 0 replies; 14+ messages in thread
From: Richard Stallman @ 2002-09-23  0:16 UTC (permalink / raw)
  Cc: emacs-devel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 355 bytes --]

    Wouldn´t then be logical to rename them? AFAIK, user functions for a
    mode FOO are usually FOO-func1, FOO-func2, not FOO-mode-func1,
    FOO-mode-func2. I don´t think changing them would cause trouble, as
    users are probably using them throug bindings in occur-mode and not
    directly with M-x.

Yes, that renaming is ok if you want to do it.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: A few questions about occur-mode
  2002-09-22 23:45     ` John Paul Wallington
@ 2002-09-23 11:04       ` Juanma Barranquero
  2002-09-23 11:50         ` Juanma Barranquero
  2002-09-23 15:59       ` Richard Stallman
  1 sibling, 1 reply; 14+ messages in thread
From: Juanma Barranquero @ 2002-09-23 11:04 UTC (permalink / raw)
  Cc: emacs-devel

On Mon, 23 Sep 2002 00:45:01 +0100, John Paul Wallington <jpw@shootybangbang.com> wrote:

> `occur-next' and `occur-prev' work in the EMACS_21_1_RC branch.

You're right. Somewhere in the big revamp of occur this functionality
was lost somehow.

> In HEAD they could be changed to use `occur-match' property instead of
> `occur-point', or `occur-engine' could add `occur-point' properties to
> its output.  Which is better ?

Using occur-match seems more economical, but then `occur-next' and
`occur-prev' should have to be modified. The occur-point property was
set in just one character at the end of the match; with occur-match, the
entire match is propertized and occur-{next|prev} would first jump to
the start of the match, then to the end. Not that is difficult, of
course. sh-script.el should have to be modified too.

OTOH, adding back occur-point is a one- or two- line change:

Index: replace.el
===================================================================
RCS file: /cvs/emacs/lisp/replace.el,v
retrieving revision 1.159
diff -u -2 -r1.159 replace.el
--- replace.el	18 Sep 2002 16:03:58 -0000	1.159
+++ replace.el	23 Sep 2002 11:03:55 -0000
@@ -822,5 +822,6 @@
 						`(font-lock-face ,match-face)))
 					     curstring)
-			(setq start (match-end 0))))
+                        (setq start (match-end 0))
+                        (put-text-property start (1+ start) 'occur-point t curstring)))
 		    ;; Generate the string to insert for this match
 		    (let* ((out-line


                                                           /L/e/k/t/u

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: A few questions about occur-mode
  2002-09-23 11:04       ` Juanma Barranquero
@ 2002-09-23 11:50         ` Juanma Barranquero
  2002-09-23 20:53           ` John Paul Wallington
  0 siblings, 1 reply; 14+ messages in thread
From: Juanma Barranquero @ 2002-09-23 11:50 UTC (permalink / raw)
  Cc: emacs-devel

On Mon, 23 Sep 2002 13:04:54 +0200, Juanma Barranquero <lektu@terra.es> wrote:

> OTOH, adding back occur-point is a one- or two- line change:

Well, in fact is more like it:

 						`(font-lock-face ,match-face)))
 					     curstring)
+                        (put-text-property (match-beginning 0) (1+ (match-beginning 0)) 'occur-point t curstring)
                        (setq start (match-end 0))))
 		    ;; Generate the string to insert for this match
 		    (let* ((out-line


because otherwise there could be problems with matches at the end of a
line. This leaves the point at the beginning of a match after M-n or M-p,
but that seems preferable IMHO.

Opinions?


                                                           /L/e/k/t/u

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: A few questions about occur-mode
  2002-09-22 23:45     ` John Paul Wallington
  2002-09-23 11:04       ` Juanma Barranquero
@ 2002-09-23 15:59       ` Richard Stallman
  2002-09-24  8:43         ` Juanma Barranquero
  1 sibling, 1 reply; 14+ messages in thread
From: Richard Stallman @ 2002-09-23 15:59 UTC (permalink / raw)
  Cc: lektu, emacs-devel

    In HEAD they could be changed to use `occur-match' property instead of
    `occur-point', or `occur-engine' could add `occur-point' properties to
    its output.  Which is better ?

I think it is cleaner to use just one property for both purposes.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: A few questions about occur-mode
  2002-09-23 11:50         ` Juanma Barranquero
@ 2002-09-23 20:53           ` John Paul Wallington
  2002-09-24  8:55             ` Juanma Barranquero
  0 siblings, 1 reply; 14+ messages in thread
From: John Paul Wallington @ 2002-09-23 20:53 UTC (permalink / raw)
  Cc: emacs-devel

Juanma Barranquero <lektu@terra.es> wrote:

> because otherwise there could be problems with matches at the end of a
> line. This leaves the point at the beginning of a match after M-n or M-p,
> but that seems preferable IMHO.
>
> Opinions?

If we put `occur-point' properties in `occur-engine' output because
of compatibility maybe they should go at the end of each match for
the same reason?   We could acomplish that by sticking a space on the
end of each line's string before propertizing it:

Index: replace.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/replace.el,v
retrieving revision 1.159
diff -u -r1.159 replace.el
*** replace.el	18 Sep 2002 16:03:58 -0000	1.159
--- replace.el	23 Sep 2002 20:46:42 -0000
***************
*** 804,811 ****
  		    (setq lines (+ lines (1- (count-lines origpt endpt))))
  		    (setq marker (make-marker))
  		    (set-marker marker matchbeg)
! 		    (setq curstring (buffer-substring begpt
! 						      (line-end-position)))
  		    ;; Depropertize the string, and maybe
  		    ;; highlight the matches
  		    (let ((len (length curstring))
--- 804,813 ----
  		    (setq lines (+ lines (1- (count-lines origpt endpt))))
  		    (setq marker (make-marker))
  		    (set-marker marker matchbeg)
! 		    (setq curstring (concat
! 				     (buffer-substring begpt
! 						       (line-end-position))
! 				     " "))
  		    ;; Depropertize the string, and maybe
  		    ;; highlight the matches
  		    (let ((len (length curstring))
***************
*** 821,826 ****
--- 823,834 ----
  					      (when match-face
  						`(font-lock-face ,match-face)))
  					     curstring)
+ 			;; `occur-point' property is used by occur-next and
+ 			;; occur-prev to move between matches.
+ 			(put-text-property (match-end 0)
+ 					   (1+ (match-end 0))
+ 					   'occur-point t 
+ 					   curstring)
  			(setq start (match-end 0))))
  		    ;; Generate the string to insert for this match
  		    (let* ((out-line

-- 
John Paul Wallington

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: A few questions about occur-mode
  2002-09-23 15:59       ` Richard Stallman
@ 2002-09-24  8:43         ` Juanma Barranquero
  2002-09-24 10:22           ` Juanma Barranquero
  2002-09-24 23:33           ` Richard Stallman
  0 siblings, 2 replies; 14+ messages in thread
From: Juanma Barranquero @ 2002-09-24  8:43 UTC (permalink / raw)
  Cc: jpw, emacs-devel

On Mon, 23 Sep 2002 11:59:53 -0400, Richard Stallman <rms@gnu.org> wrote:

> I think it is cleaner to use just one property for both purposes.

Ok. I've modified `occur-next' and `occur-prev' to use 'occur-match.

Still, someone knowledgeable on progmodes/sh-script.el should redo
`sh-learn-buffer-indent' and friends.


                                                           /L/e/k/t/u

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: A few questions about occur-mode
  2002-09-23 20:53           ` John Paul Wallington
@ 2002-09-24  8:55             ` Juanma Barranquero
  0 siblings, 0 replies; 14+ messages in thread
From: Juanma Barranquero @ 2002-09-24  8:55 UTC (permalink / raw)
  Cc: emacs-devel

On Mon, 23 Sep 2002 21:53:52 +0100, John Paul Wallington <jpw@shootybangbang.com> wrote:

> If we put `occur-point' properties in `occur-engine' output because
> of compatibility maybe they should go at the end of each match for
> the same reason?

Richard has suggested using just one property, so I've chosen
'occur-match, which seems the cleaner method.  The fixes for `occur-next'
and `occur-prev' are pretty straightforward, and now they work as
previously did, AFAICS.


                                                           /L/e/k/t/u

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: A few questions about occur-mode
  2002-09-24  8:43         ` Juanma Barranquero
@ 2002-09-24 10:22           ` Juanma Barranquero
  2002-09-24 23:33             ` Richard Stallman
  2002-09-24 23:33           ` Richard Stallman
  1 sibling, 1 reply; 14+ messages in thread
From: Juanma Barranquero @ 2002-09-24 10:22 UTC (permalink / raw)
  Cc: jpw, emacs-devel

On Tue, 24 Sep 2002 10:43:57 +0200, Juanma Barranquero <lektu@terra.es> wrote:

> Still, someone knowledgeable on progmodes/sh-script.el should redo
> `sh-learn-buffer-indent' and friends.

Ok, I've done a first cut at fixing `sh-learn-buffer-indent' and it
seems to be working. At least it pops a buffer that you can use with M-n,
M-p and C-c C-c to get to the right places.

But as I had no previous experience with sh-script.el, I'd suggest
someone who does to take a look at it.

Thanks,

                                                           /L/e/k/t/u

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: A few questions about occur-mode
  2002-09-24  8:43         ` Juanma Barranquero
  2002-09-24 10:22           ` Juanma Barranquero
@ 2002-09-24 23:33           ` Richard Stallman
  1 sibling, 0 replies; 14+ messages in thread
From: Richard Stallman @ 2002-09-24 23:33 UTC (permalink / raw)
  Cc: jpw, emacs-devel

    Ok. I've modified `occur-next' and `occur-prev' to use 'occur-match.

Thank you.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: A few questions about occur-mode
  2002-09-24 10:22           ` Juanma Barranquero
@ 2002-09-24 23:33             ` Richard Stallman
  0 siblings, 0 replies; 14+ messages in thread
From: Richard Stallman @ 2002-09-24 23:33 UTC (permalink / raw)
  Cc: jpw, emacs-devel

    > Still, someone knowledgeable on progmodes/sh-script.el should redo
    > `sh-learn-buffer-indent' and friends.

    Ok, I've done a first cut at fixing `sh-learn-buffer-indent' and it
    seems to be working. At least it pops a buffer that you can use with M-n,
    M-p and C-c C-c to get to the right places.

Thank you.

    But as I had no previous experience with sh-script.el, I'd suggest
    someone who does to take a look at it.

I'd be surprised if any of us knows that code better than you do.

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2002-09-24 23:33 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-09-20 11:44 A few questions about occur-mode Juanma Barranquero
2002-09-21 19:39 ` Richard Stallman
2002-09-22 17:32   ` Juanma Barranquero
2002-09-22 23:45     ` John Paul Wallington
2002-09-23 11:04       ` Juanma Barranquero
2002-09-23 11:50         ` Juanma Barranquero
2002-09-23 20:53           ` John Paul Wallington
2002-09-24  8:55             ` Juanma Barranquero
2002-09-23 15:59       ` Richard Stallman
2002-09-24  8:43         ` Juanma Barranquero
2002-09-24 10:22           ` Juanma Barranquero
2002-09-24 23:33             ` Richard Stallman
2002-09-24 23:33           ` Richard Stallman
2002-09-23  0:16     ` Richard Stallman

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).