emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* odd behaviour in a function - looking for advice
@ 2011-06-17  1:34 Filippo A. Salustri
  2011-06-17  1:46 ` Jambunathan K
  0 siblings, 1 reply; 6+ messages in thread
From: Filippo A. Salustri @ 2011-06-17  1:34 UTC (permalink / raw)
  To: emacs-orgmode mailing list

Hi all,

I've got this function:

(defun fas/org-priority (&optional p)
  "Change the priority of the current item, then refresh agenda."
  (interactive)
  (save-excursion
    (if (org-priority p)
        (org-agenda-redo))))

I set up my window to have 2 frames side by side.  The org agenda is
in the left frame.  In the right frame is whatever org file I'm
working on.
In the org file (right frame), I call the above function, having bound
it to \C-,
It does what it's supposed to to the priority, but then the point
moves to the agenda frame and goes to the end of the agenda buffer.
I would have thought 'save-excursion' would have returned the point to
wherever I was when I called the function.

Anyone got any idea what I'm doing wrong?
Cheers.
Fil

-- 
\V/_
Filippo A. Salustri, Ph.D., P.Eng.
Mechanical and Industrial Engineering
Ryerson University
350 Victoria St, Toronto, ON
M5B 2K3, Canada
Tel: 416/979-5000 ext 7749
Fax: 416/979-5265
Email: salustri@ryerson.ca
http://deseng.ryerson.ca/~fil/

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

* Re: odd behaviour in a function - looking for advice
  2011-06-17  1:34 Filippo A. Salustri
@ 2011-06-17  1:46 ` Jambunathan K
  2011-06-17  1:56   ` Jambunathan K
  2011-06-17  2:01   ` Filippo A. Salustri
  0 siblings, 2 replies; 6+ messages in thread
From: Jambunathan K @ 2011-06-17  1:46 UTC (permalink / raw)
  To: Filippo A. Salustri; +Cc: emacs-orgmode mailing list

"Filippo A. Salustri" <salustri@ryerson.ca> writes:

> Hi all,
>
> I've got this function:
>
> (defun fas/org-priority (&optional p)
>   "Change the priority of the current item, then refresh agenda."
>   (interactive)
>   (save-excursion
>     (if (org-priority p)
>         (org-agenda-redo))))
>
> I set up my window to have 2 frames side by side.  The org agenda is
> in the left frame.  In the right frame is whatever org file I'm
> working on.
> In the org file (right frame), I call the above function, having bound
> it to \C-,
> It does what it's supposed to to the priority, but then the point
> moves to the agenda frame and goes to the end of the agenda buffer.
> I would have thought 'save-excursion' would have returned the point to
> wherever I was when I called the function.
>

save-window-excursion maybe? 
Or you could solve the problem by one switch-to-buffer-other-window.

Just a quick hint.

> Anyone got any idea what I'm doing wrong?
> Cheers.
> Fil

-- 

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

* Re: odd behaviour in a function - looking for advice
  2011-06-17  1:46 ` Jambunathan K
@ 2011-06-17  1:56   ` Jambunathan K
  2011-06-17  2:01   ` Filippo A. Salustri
  1 sibling, 0 replies; 6+ messages in thread
From: Jambunathan K @ 2011-06-17  1:56 UTC (permalink / raw)
  To: Filippo A. Salustri; +Cc: emacs-orgmode mailing list

Jambunathan K <kjambunathan@gmail.com> writes:

> "Filippo A. Salustri" <salustri@ryerson.ca> writes:
>
>> Hi all,
>>
>> I've got this function:
>>
>> (defun fas/org-priority (&optional p)
>>   "Change the priority of the current item, then refresh agenda."
>>   (interactive)
>>   (save-excursion
>>     (if (org-priority p)
>>         (org-agenda-redo))))
>>
>> I set up my window to have 2 frames side by side.  The org agenda is
>> in the left frame.  In the right frame is whatever org file I'm
>> working on.
>> In the org file (right frame), I call the above function, having bound
>> it to \C-,
>> It does what it's supposed to to the priority, but then the point
>> moves to the agenda frame and goes to the end of the agenda buffer.
>> I would have thought 'save-excursion' would have returned the point to
>> wherever I was when I called the function.
>>
>
> save-window-excursion maybe? 
> Or you could solve the problem by one switch-to-buffer-other-window.
>
> Just a quick hint.

Also look at window-buffer or functions that start with
window-configuration-*.

Disclaimer: I cannot assure that the solution I suggest would work or is
correct but they sound like good starting points.

>
>> Anyone got any idea what I'm doing wrong?
>> Cheers.
>> Fil

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

* Re: odd behaviour in a function - looking for advice
  2011-06-17  1:46 ` Jambunathan K
  2011-06-17  1:56   ` Jambunathan K
@ 2011-06-17  2:01   ` Filippo A. Salustri
  1 sibling, 0 replies; 6+ messages in thread
From: Filippo A. Salustri @ 2011-06-17  2:01 UTC (permalink / raw)
  To: Jambunathan K; +Cc: emacs-orgmode mailing list

save-window-excursion did the trick.  Never heard of that one.
Thanks!
Cheers.
Fil

On 16 June 2011 21:46, Jambunathan K <kjambunathan@gmail.com> wrote:
> "Filippo A. Salustri" <salustri@ryerson.ca> writes:
>
>> Hi all,
>>
>> I've got this function:
>>
>> (defun fas/org-priority (&optional p)
>>   "Change the priority of the current item, then refresh agenda."
>>   (interactive)
>>   (save-excursion
>>     (if (org-priority p)
>>         (org-agenda-redo))))
>>
>> I set up my window to have 2 frames side by side.  The org agenda is
>> in the left frame.  In the right frame is whatever org file I'm
>> working on.
>> In the org file (right frame), I call the above function, having bound
>> it to \C-,
>> It does what it's supposed to to the priority, but then the point
>> moves to the agenda frame and goes to the end of the agenda buffer.
>> I would have thought 'save-excursion' would have returned the point to
>> wherever I was when I called the function.
>>
>
> save-window-excursion maybe?
> Or you could solve the problem by one switch-to-buffer-other-window.
>
> Just a quick hint.
>
>> Anyone got any idea what I'm doing wrong?
>> Cheers.
>> Fil
>
> --
>



-- 
\V/_
Filippo A. Salustri, Ph.D., P.Eng.
Mechanical and Industrial Engineering
Ryerson University
350 Victoria St, Toronto, ON
M5B 2K3, Canada
Tel: 416/979-5000 ext 7749
Fax: 416/979-5265
Email: salustri@ryerson.ca
http://deseng.ryerson.ca/~fil/

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

* Re: odd behaviour in a function - looking for advice
@ 2011-06-17 10:12 Rustom Mody
  0 siblings, 0 replies; 6+ messages in thread
From: Rustom Mody @ 2011-06-17 10:12 UTC (permalink / raw)
  To: emacs-orgmode

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

[OT for this discussion but just wondering if Jambunathan's suggestions may
work here]

There has been this question asked both on the emacs and on the python list

Just excerpting from
http://groups.google.com/group/comp.lang.python/browse_thread/thread/acb0f2a01fe50151#

I am using python-mode to write python code in Emacs, and when I use the
useful C-c C-c key combination to interpret the buffer, Emacs always
opens another window inside the window I am using.

I prefer using Emacs split in two windows (one on each physical screen)
where I program in one of them and use the Python interpreter in the
other.  Is there a way I can tell Emacs to use the *Python* buffer in
the Window that is already open instead of creating a new one?

[-- Attachment #2: Type: text/html, Size: 1050 bytes --]

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

* Re: odd behaviour in a function - looking for advice
@ 2011-06-17 12:54 Rustom Mody
  0 siblings, 0 replies; 6+ messages in thread
From: Rustom Mody @ 2011-06-17 12:54 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: kjambunathan

[OT for this discussion but just wondering if Jambunathan's
suggestions may work here]

There has been this question asked both on the emacs and on the python list

Just excerpting from
http://groups.google.com/group/comp.lang.python/browse_thread/thread/acb0f2a01fe50151#

I am using python-mode to write python code in Emacs, and when I use the
useful C-c C-c key combination to interpret the buffer, Emacs always
opens another window inside the window I am using.

I prefer using Emacs split in two windows (one on each physical screen)
where I program in one of them and use the Python interpreter in the
other.  Is there a way I can tell Emacs to use the *Python* buffer in
the Window that is already open instead of creating a new one?

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

end of thread, other threads:[~2011-06-17 14:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-17 10:12 odd behaviour in a function - looking for advice Rustom Mody
  -- strict thread matches above, loose matches on Subject: below --
2011-06-17 12:54 Rustom Mody
2011-06-17  1:34 Filippo A. Salustri
2011-06-17  1:46 ` Jambunathan K
2011-06-17  1:56   ` Jambunathan K
2011-06-17  2:01   ` Filippo A. Salustri

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

	https://git.savannah.gnu.org/cgit/emacs/org-mode.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).