Yes, I think I used to do that but before the hardware problem cropped up (if that's what it is, probably overheating) I would eventually transfer blocks of text composed there into an appropriate file-visiting buffer. The append region to file isn't the ideal solution either, because it requires multiple appends as the text changes and grows, so if the laptop shuts down (usually when I have left it for a long time without putting it to sleep) then I have to get the latest versions of text blocks from the bottom of the file. Of couse the root of the problem is my idiosyncratic use of *scratch*.  I put urls there instead of using browser history, utf-8 encoded text to copy-paste into Thunderbird or into a latex file, and many other things.

Thanks, again.

Ed


On 5/18/2019 10:48, Francis Wright wrote:

I’m glad that’s resolved.


I think the point of the scratch buffer is that it’s intended for transient information that doesn’t need to be preserved. You could visit the file scratch.txt when you start an Emacs session and use its buffer instead of **scratch**.

Best wishes, Francis

*From:*T400 <cau...@sysmatrix.net>
*Sent:* Saturday, 18 May 2019 4:39 pm
*To:* Francis Wright <f.j.wri...@live.co.uk>
*Cc:* help-emacs-windows@gnu.org
*Subject:* Re: [h-e-w] interactive "r" argument passing

Thanks, again. The problem wasn't with the function but with a faulty defalias form, with which I called the function. Now I have (correctly):

(defalias 'sch 'save-sscratch)

I was losing the contents of *scratch* because  of unexpected shutdowns and because that buffer is not normally associated with any file. Maybe it would be a good idea to save the buffer to starscratch.txt on start up so that later it might be recovered if need be (with recover-this-file). Emacs dev would know how to make it do what I mean.

Ed

On 5/18/2019 06:54, Francis Wright wrote:

    Just to follow up on what I wrote below, the following version of
    your function works fine for me (on Windows 10) and writes the
    file to my default Documents folder:

    (defun save-sscratch (start end)

      "Append region in *scratch* to file scratch.txt."

      (interactive "r")

    (with-current-buffer "*scratch*"

        (write-region start end "c:/Users/fjw/Documents/scratch.txt" t)))

    I think your problem is the way you have specified the folder that
    you want to write to.

    *From:*help-emacs-windows
    <help-emacs-windows-bounces+f.j.wright=live.co...@gnu.org>
    <mailto:help-emacs-windows-bounces+f.j.wright=live.co...@gnu.org>
    *On Behalf Of *Francis Wright
    *Sent:* Saturday, 18 May 2019 9:57 am
    *To:* T400 <cau...@sysmatrix.net> <mailto:cau...@sysmatrix.net>;
    help-emacs-windows@gnu.org <mailto:help-emacs-windows@gnu.org>
    *Subject:* Re: [h-e-w] interactive "r" argument passing

    If this still doesn't work then I suggest you visit the file you
    want to write to in Emacs and copy the full filename used by Emacs
    into your function. I'll look at this more carefully later.

    Get Outlook for Android <https://aka.ms/ghei36>

    ------------------------------------------------------------------------

    *From:* help-emacs-windows
    <help-emacs-windows-bounces+f.j.wright=live.co...@gnu.org
    <mailto:help-emacs-windows-bounces+f.j.wright=live.co...@gnu.org>>
    on behalf of T400 <cau...@sysmatrix.net <mailto:cau...@sysmatrix.net>>
    *Sent:* Saturday, May 18, 2019 6:03:46 AM
    *To:* help-emacs-windows@gnu.org <mailto:help-emacs-windows@gnu.org>
    *Subject:* Re: [h-e-w] interactive "r" argument passing

    Thanks, Francis. I tried escaped backslashes and slashes. After this
    didn't work either:


    (defun save-sscratch (start end) ;; M-x sch
    "Append region in *scratch* to file scratch.txt."
    (interactive "r")
    (with-current-buffer "*scratch*"
        (write-region start end "c:/mydocu~1/scratch.txt" t)))


    I noticed that the in the alias def for sch the 'save-sscratch'
    function
    name was spelled wrong.

    ;-(

    Ed

    On 5/17/2019 12:18, Francis Wright wrote:
    > You need to double the backslashes or use forward slashes;
    either should work. (And there should be no need to shorten
    filenames.)
    >
    > Francis
    >
    >> -----Original Message-----
    >> From: help-emacs-windows <help-emacs-windows-
    >> bounces+f.j.wright=live.co...@gnu.org
    <mailto:bounces+f.j.wright=live.co...@gnu.org>> On Behalf Of T400
    >> Sent: Friday, 17 May 2019 6:01 pm
    >> To: w32emacs <help-emacs-windows@gnu.org
    <mailto:help-emacs-windows@gnu.org>>
    >> Subject: [h-e-w] interactive "r" argument passing
    >>
    >> Dear w32 emacs gurus:
    >>
    >> Why does this function not work? I think that similar functions
    I wrote long
    >> ago did work.:
    >>
    >>
    >> (defun save-sscratch (start end) ;; M-x sch alias
    >> "Append region in *scratch* to file scratch.txt"
    >> (interactive "r")
    >> (with-current-buffer "*scratch*"
    >>      (append-to-file start end "c:\mydocu~1\scratch.txt")))
    >>
    >> Do I need escaped backslashes? forward slashes?
    >>
    >>
    >> Thanks,
    >>
    >> Ed
    >>
    >>

Reply via email to