From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: John Mastro Newsgroups: gmane.emacs.help Subject: Re: how to get around deprecated function Date: Tue, 5 May 2015 10:13:07 -0700 Message-ID: References: <87twvzx252.fsf@debian.uxu> <87y4l9p04r.fsf@debian.uxu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1430846030 12109 80.91.229.3 (5 May 2015 17:13:50 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 5 May 2015 17:13:50 +0000 (UTC) To: "B. T. Raven" , "help-gnu-emacs@gnu.org" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue May 05 19:13:50 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YpgPl-0005Gz-Kb for geh-help-gnu-emacs@m.gmane.org; Tue, 05 May 2015 19:13:49 +0200 Original-Received: from localhost ([::1]:40904 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YpgPl-0001DN-0E for geh-help-gnu-emacs@m.gmane.org; Tue, 05 May 2015 13:13:49 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33951) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YpgPU-0001Ad-M5 for help-gnu-emacs@gnu.org; Tue, 05 May 2015 13:13:33 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YpgPQ-0000OO-Vd for help-gnu-emacs@gnu.org; Tue, 05 May 2015 13:13:32 -0400 Original-Received: from mail-oi0-x230.google.com ([2607:f8b0:4003:c06::230]:32981) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YpgPQ-0000OE-RP for help-gnu-emacs@gnu.org; Tue, 05 May 2015 13:13:28 -0400 Original-Received: by oica37 with SMTP id a37so151830257oic.0 for ; Tue, 05 May 2015 10:13:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=wzQaVbNdbnPHCp+Yz+Pj/2i6OBjYWd831ybaXjg6FAw=; b=YXqK8G99+4vHLQ8S/NMmDJsJHUIaQ1nQTjSYqk/6MBYSDhazDnRtv9Aj95Fj9ugS4S wAPo0LFr2sboud0qA8rEg5yHUXHE420XNPETgVGoCBwdzZodA+R8JExRzRIPOF/aUCEq OgTIZS8+t6P048+03VMb7m2bMLuaWuLxNSfLRsHgRuYEfKrf7H843zzkIshJWwI2/x3E vYJRKc2BtHxuYTtJf27CxMyGlJY+uvkKw4SSti/OYJoXbwwoJluVEKt1Ia8GiN2zHxpM 7RwyNp3UC/eopuGkUpNl+aVzFIOYJjc35PUk2zkpIAsokcHFsHmDhPA9dGe952KKd8zA tM/w== X-Received: by 10.202.83.202 with SMTP id h193mr22322742oib.56.1430846008132; Tue, 05 May 2015 10:13:28 -0700 (PDT) Original-Received: by 10.76.168.70 with HTTP; Tue, 5 May 2015 10:13:07 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4003:c06::230 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:104219 Archived-At: 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