unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* server emacs - how to get file/line/col of previous buffer?
@ 2008-03-08 14:20 Michal
  0 siblings, 0 replies; 4+ messages in thread
From: Michal @ 2008-03-08 14:20 UTC (permalink / raw)
  To: emacs mailing list


Hallo Group members!
I added following functions to server*-hook:

(add-hook 'server-switch-hook
	  (function (lambda () 
		      (message "%s: server-switch-hook" (buffer-name)))))

(add-hook 'server-visit-hook
	  (function (lambda () 
		      (message "%s: server-visit-hook" (buffer-name)))))


then,

M-x server-start

then from outside emacs:

$ emacsclient --no-wait /tmp/p1.c


emacs produces following message:

p1.c: server-visit-hook
p1.c: server-switch-hook


... but, Have You got idea on how to get info about buffer we jumped from?

Regards,
Michal




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

* Re: server emacs - how to get file/line/col of previous buffer?
       [not found] <mailman.8560.1204991147.18990.help-gnu-emacs@gnu.org>
@ 2008-03-08 21:27 ` Stefan Monnier
  2008-03-09 11:44   ` Michal
  2008-03-09 16:59   ` Michal
  0 siblings, 2 replies; 4+ messages in thread
From: Stefan Monnier @ 2008-03-08 21:27 UTC (permalink / raw)
  To: help-gnu-emacs

> ... but, Have You got idea on how to get info about buffer we jumped from?

It's not clear to me which "from" buffer you're thinking of (there's
the buffer from which the server processed your request, the buffer
that was displayed in the window in which your file gets displayed, and
probably a few more).

In any case, I think is answer is "no".  But if you explain what you're
trying to do, maybe we can help you solve it differently.


        Stefan


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

* Re: server emacs - how to get file/line/col of previous buffer?
  2008-03-08 21:27 ` Stefan Monnier
@ 2008-03-09 11:44   ` Michal
  2008-03-09 16:59   ` Michal
  1 sibling, 0 replies; 4+ messages in thread
From: Michal @ 2008-03-09 11:44 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> It's not clear to me which "from" buffer you're thinking of (there's
> the buffer from which the server processed your request, the buffer
> that was displayed in the window in which your file gets displayed, and
> probably a few more).

I mean "the buffer that was displayed in the window in which your file
gets displayed".

This is the description what I need to do:

I want to add two icon buttons: "<-" and "->" to the end of list of
buttons, that are at the top of emacs window (I am using emacs under X
of course). These two buttons will move me through the list of
locations(buffer/line/col).

What locations' list is?

I explain it on example.

1) I run emacs as usual.
2) then I do M-x server-start on it.
3) then I visit location: L1 = p1.c/23/4, where 23 is line number, and 4 is column number.
4) then in external terminal I do:
   emacsclient --no-wait  +10:5 p2 #. L2 = p2.c/10/5. Note: --no-wait flag
   At this point emacs put two locations on the list:
        L2        L1
   (p2.c/10/5 p1.c/23/4)
5) Now I do some editing in p2.c buffer, then some other buffers,
   but finally I end up in location: L3 = p3.c/30/5.
6) Now: emacsclient --no-wait  +20:30 p4 #. L4 = p4/20/30
   At this point my list should look like following:
       L4        L3         L2      L1
   (p4/20/30 p3.c/30/5 p2.c/10/5 p1.c/23/4)
7) Now: emacsclient --no-wait  +15:16 p5 #. L5 = p5/15/16. 
                                         #. cursor not moved away from p4/20/30 location.
                                         #. ... so only one location is added...

       L5       L4       L3       L2         L1
   (p5/15/16 p4/20/30 p3.c/30/5 p2.c/10/5 p1.c/23/4)

8) Now I press: "<-" button, which displays L4 location.
9) Once more "<-". Displays L3 location.
10) Now "->" goes back to L4 location.
11) Now: emacsclient --no-wait  +7:3 p5 #. L6 = p5/7/3.
      L6      L4       L3       L2         L1
   (p5/7/3 p4/20/30 p3.c/30/5 p2.c/10/5 p1.c/23/4)

Note: L5 (and all follwing in they existed) is forgotten , because I was at L4, when emacsclient
      is invoked.

Summary: My list is modified only at emacsclient invocations. At most two locations are added at each invocation. But if last location at the list is the same as the one being displayed in emacs just at (before) emacsclient invocation, then only one location is added. This is the one described by emacsclient invocation params.

This is what I want to do.

Regards,
Michal





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

* Re: server emacs - how to get file/line/col of previous buffer?
  2008-03-08 21:27 ` Stefan Monnier
  2008-03-09 11:44   ` Michal
@ 2008-03-09 16:59   ` Michal
  1 sibling, 0 replies; 4+ messages in thread
From: Michal @ 2008-03-09 16:59 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs

Stefan,
I already know how to do that.
I am planning to use advice to server-visit-files.

best regards,
Michal

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> ... but, Have You got idea on how to get info about buffer we jumped from?
>
> It's not clear to me which "from" buffer you're thinking of (there's
> the buffer from which the server processed your request, the buffer
> that was displayed in the window in which your file gets displayed, and
> probably a few more).
>
> In any case, I think is answer is "no".  But if you explain what you're
> trying to do, maybe we can help you solve it differently.
>
>
>         Stefan




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

end of thread, other threads:[~2008-03-09 16:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-08 14:20 server emacs - how to get file/line/col of previous buffer? Michal
     [not found] <mailman.8560.1204991147.18990.help-gnu-emacs@gnu.org>
2008-03-08 21:27 ` Stefan Monnier
2008-03-09 11:44   ` Michal
2008-03-09 16:59   ` Michal

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).