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

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

replace-in-string and backward-delete-char [help request!]


From: Joe Corneli
Subject: replace-in-string and backward-delete-char [help request!]
Date: Mon, 18 Nov 2002 00:06:13 -0600

Hello --

I am running XEmacs version 21.5  (beta4) "bamboo"  for
darwin 6.0.   I expect that won't be hugely relevant but
thought I should mention it before proceeding.

I wrote the following code (below). It has 2 problems. The first
is that replace-in-string does not seem to have any effect.
The second is that backward-delete-char copies the deleted stuff
to the kill ring even though I ask it not to (at least
I think that I'm interpreting the documentation properly by
adding an explicit "nil" at the end. -- Behavior is the same
for me when I put nothing after the "3").

Suggestions?  I'm open to someone rewriting the code entirely
if he or she has a better way to do this. I just want it
to work....

Thanks,
Joe Corneli

(defun cite-last-n-words (n)
"Copy last ARG words to point and wrap with TeX citation markup."
  (interactive "p")
  (backward-kill-word n)
  (yank)
  (insert " \\cite{")
  (kill-new
  ; stuff I can't get to work properly--------
    (replace-in-string
     (replace-in-string
      (prin1-to-string (yank))
      " " "_")
     "[\n]" "_")
  ; --------stuff I can't get to work properly
   )
  (yank)

  ;; need to rid of trailing nil... but I don't like it being added to
  ;; kill ring even though I indicate I don't want it there.
  (backward-delete-char 3 nil)
  (delete-horizontal-space)
  (insert "} ")
  )





reply via email to

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