unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: "B. T. Raven" <btraven@nihilo.net>
To: help-gnu-emacs@gnu.org
Subject: Re: how to get around deprecated function
Date: Thu, 30 Apr 2015 13:01:34 -0500	[thread overview]
Message-ID: <55426DFE.2050600@nihilo.net> (raw)
In-Reply-To: <87twvzx252.fsf@debian.uxu>

Die Tue Apr 28 2015 18:29:45 GMT-0500 (Central Daylight Time) Emanuel
Berg <embe8573@student.uu.se> scripsit:

> B. T. Raven <btraven@nihil.net> writes:
> 
>> I am constantly losing short pieces of text left in
>> *scratch* and I wrote this interactive function
>> [...]
>>
>> It "works" but according to the docs
>> mark-whole-buffer shouldn't be used this way.
>> Is there an understandable (to me) right way of
>> doing this or doing something else that can be
>> invoked as easily?
> 
> In the help for `append-to-file', it says
> 
>     (append-to-file START END FILENAME) ... If START
>     is nil, that means to use the entire
>     buffer contents.
> 
> Also, instead of using `switch-to-buffer', use
> `with-current-buffer'. And, instead of using `setq',
> use `let'. Or - as the data doesn't reappear - you
> might as well put the function invocations in the
> append-to-file invocation itself.
> 
> Use the Emacs byte-compiler to get suggestions such as
> these. You already found out they are in the help, but
> the byte-compiler can be a way of not having to check
> the help for every function used...
> 
> Meta hint: Don't quote things that haven't appeared in
> the thread with the angle brackets. Either just yank
> it or make it look like this if it appeals to you:
> 
>     Meta hint: don't quote things that haven't
>     appeared in the thread with the angle brackets.
>     Either just yank it or make it look like this if
>     it appeals to you.
> 
> Dig deep!
> 

Thanks, Emanuel and Rusi. GT signs are there because I copypasted out of
gnus.help where I posted by mistake. I should have stripped them.

I now have:

Not exactly what you do but for the same reason I have:

(defun save-scratchtemp ();; M-x sch
 (interactive)
(save-excursion
 (with-current-buffer "*scratch*"
      (mark-whole-buffer)
   ;;(setq start (point) end (mark))
     (append-to-file nil nil "c:/mydocu~1/scratchtemp.txt")))
)

which also "works." Also I may not need save-excursion even if my
current buffer is not *scratch*. I used nil nil for start, end maybe
unnecessarily if append-to-file renumbers the argument list.

I think that the add-hook won't work for me:

(add-hook 'lisp-interaction-mode-hook
	  (function (lambda () (setq buffer-offer-save t))))

because *scratch* would have to be associated with a file name which
would replace the *scratch* buffer. My kludge is pretty hokey but at
least I understand it and the multiple copies of the same -short
stretches of text won't be a cumulative problem if I just delete the
scratchtemp.txt file now and then.

Ed


  reply	other threads:[~2015-04-30 18:01 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-28 22:59 how to get around deprecated function B. T. Raven
2015-04-28 23:29 ` Emanuel Berg
2015-04-30 18:01   ` B. T. Raven [this message]
2015-05-01  1:17     ` Emanuel Berg
2015-05-01  3:55       ` hook syntax (was: Re: how to get around deprecated function) Emanuel Berg
2015-05-01  4:06         ` Emanuel Berg
2015-05-03 23:54         ` hook syntax Stefan Monnier
     [not found]         ` <mailman.2274.1430697294.904.help-gnu-emacs@gnu.org>
2015-05-05  2:07           ` --batch on many files without reloading config (was: Re: hook syntax) Emanuel Berg
2015-05-05 11:28             ` --batch on many files without reloading config Stefan Monnier
2015-05-05 16:45               ` hooks, again (was: Re: --batch on many files without reloading config) Emanuel Berg
2015-05-05 22:09                 ` hooks, again Stefan Monnier
     [not found]                 ` <mailman.2431.1430863781.904.help-gnu-emacs@gnu.org>
2015-05-06  0:05                   ` Emanuel Berg
2015-05-06  2:55                     ` Stefan Monnier
     [not found]                     ` <mailman.2436.1430880949.904.help-gnu-emacs@gnu.org>
2015-05-06  3:25                       ` Emanuel Berg
2015-05-06  4:08                         ` Stefan Monnier
2015-05-06 19:17                           ` Emanuel Berg
2015-05-06 20:31                             ` Stefan Monnier
     [not found]                             ` <mailman.2490.1430944327.904.help-gnu-emacs@gnu.org>
2015-05-06 22:21                               ` Emanuel Berg
2015-05-06 22:30                                 ` Stefan Monnier
     [not found]                                 ` <mailman.2504.1430951419.904.help-gnu-emacs@gnu.org>
2015-05-10 17:52                                   ` Emanuel Berg
2015-05-05 15:41       ` how to get around deprecated function B. T. Raven
2015-05-05 17:13         ` John Mastro
2015-05-05 17:31         ` Emanuel Berg
     [not found]         ` <mailman.2404.1430846015.904.help-gnu-emacs@gnu.org>
2015-05-05 17:39           ` Emanuel Berg
2015-04-29  2:55 ` Rusi
2015-04-29 22:06 ` Xavier Maillard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55426DFE.2050600@nihilo.net \
    --to=btraven@nihilo.net \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).