unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Positioning point after insert in another buffer
@ 2004-12-09 18:28 francis
  0 siblings, 0 replies; 3+ messages in thread
From: francis @ 2004-12-09 18:28 UTC (permalink / raw)



I am internationalising an application, and am trying to write a simple
emacs lisp function to kill the current region, insert a message into a
resource file in another buffer and then insert code to retrieve and
display the message.

The problem I have is that after I have executed my function the point
in the resource file is at the beginning of the inserted message. I
want it to be at the end, so when I run my function several times the
messages appear in the resource file in the order I created them. How
can I do this?

Here's the function:

(defvar fjdjava-message-buffer-name "ApplicationResources.properties")
(defun fjdjava-region-to-message (key)
  "Converts the region into a message in the buffer named
`fjdjava-message-buffer-name'"
  (interactive "sMessage key: \n")
  (kill-region (point) (mark))
  (save-excursion
    (set-buffer fjdjava-message-buffer-name)
    (insert key " = ")
    (yank)
    (insert "\n"))
  (insert "<bean:message key=\"" key "\" />"))

Thanks,

Francis.

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

* Re: Positioning point after insert in another buffer
       [not found] <mailman.4795.1102617658.27204.help-gnu-emacs@gnu.org>
@ 2004-12-09 18:52 ` Thien-Thi Nguyen
  2004-12-10  3:50 ` Stefan Monnier
  1 sibling, 0 replies; 3+ messages in thread
From: Thien-Thi Nguyen @ 2004-12-09 18:52 UTC (permalink / raw)


<francis@devrx.org> writes:

>   (kill-region (point) (mark))

change to: set a variable to `(buffer-substring (point) (mark))'.

>     (yank)

change to: insert the value of the variable.

thi

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

* Re: Positioning point after insert in another buffer
       [not found] <mailman.4795.1102617658.27204.help-gnu-emacs@gnu.org>
  2004-12-09 18:52 ` Positioning point after insert in another buffer Thien-Thi Nguyen
@ 2004-12-10  3:50 ` Stefan Monnier
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2004-12-10  3:50 UTC (permalink / raw)


> The problem I have is that after I have executed my function the point
> in the resource file is at the beginning of the inserted message. I
> want it to be at the end, so when I run my function several times the
> messages appear in the resource file in the order I created them. How
> can I do this?

See (info "(elisp)Window Point") for an explanation.

> (defvar fjdjava-message-buffer-name "ApplicationResources.properties")
> (defun fjdjava-region-to-message (key)
>   "Converts the region into a message in the buffer named
> `fjdjava-message-buffer-name'"
>   (interactive "sMessage key: \n")
>   (kill-region (point) (mark))
>   (save-excursion
>     (set-buffer fjdjava-message-buffer-name)
>     (insert key " = ")
>     (yank)
>     (insert "\n"))
>   (insert "<bean:message key=\"" key "\" />"))

  (defvar fjdjava-message-buffer-name "ApplicationResources.properties")
  (defun fjdjava-region-to-message (key)
    "Converts the region into a message in the buffer named
  `fjdjava-message-buffer-name'"
    (interactive "sMessage key: \n")
    (let ((text (delete-and-extract-region (region-beginning) (region-end))))
      (with-current-buffer fjdjava-message-buffer-name
        (insert key " = " text "\n")
        ;; Move cursor in the window that displays this buffer.
        (let ((win (get-buffer-window (current-buffer) 0)))
          (if win (set-window-point (point))))))
    (insert "<bean:message key=\"" key "\" />"))


-- Stefan

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

end of thread, other threads:[~2004-12-10  3:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.4795.1102617658.27204.help-gnu-emacs@gnu.org>
2004-12-09 18:52 ` Positioning point after insert in another buffer Thien-Thi Nguyen
2004-12-10  3:50 ` Stefan Monnier
2004-12-09 18:28 francis

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