help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Positioning point after insert in another buffer


From: Stefan Monnier
Subject: Re: Positioning point after insert in another buffer
Date: Fri, 10 Dec 2004 03:50:09 GMT
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (gnu/linux)

> 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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]