unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: John Mastro <john.b.mastro@gmail.com>
To: "B. T. Raven" <btraven@nihil.net>,
	"help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Subject: Re: how to get around deprecated function
Date: Tue, 5 May 2015 10:13:07 -0700	[thread overview]
Message-ID: <CAOj2CQQwmcuHb5ZMWaMhNp_SDMqry0z3kJHSMxi5frzK_6nH+g@mail.gmail.com> (raw)
In-Reply-To: <miaoc502khq@drn.newsguy.com>

Hi B. T.,

> The following related function might also benefit from some
> "subtractional betterment" in case you care to comment. This just
> appends the line where cursor (or maybe more accurately 'point')
> happens to be to the *scratch* buffer. I know I can make beg, end
> local to function by using let instead of setq but I always
> re-initialize beg and end:
>
>
> (defun append-line-to-starscratch ();; M-x asl
> (interactive)
> (move-beginning-of-line nil)
> (set-mark-command nil) (setq beg (point))
> (move-end-of-line nil) (setq end (point))
> (kill-ring-save beg end)
> (with-current-buffer "*scratch*"
>      (end-of-buffer) (insert "\n")
>      (yank)))
>

Here's a simplified version, which also adds the feature that it will
use the active region, if any, or the current line otherwise.

    (defun append-to-starscratch (beg end)
      (interactive
       (if (use-region-p)
           (list (region-beginning) (region-end))
         (list (line-beginning-position) (line-end-position))))
      (let ((str (buffer-substring beg end)))
        (with-current-buffer (get-buffer-create "*scratch*")
          (goto-char (point-max))
          (insert "\n" str))))

-- 
john



  reply	other threads:[~2015-05-05 17:13 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
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 [this message]
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=CAOj2CQQwmcuHb5ZMWaMhNp_SDMqry0z3kJHSMxi5frzK_6nH+g@mail.gmail.com \
    --to=john.b.mastro@gmail.com \
    --cc=btraven@nihil.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).