From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Newsgroups: gmane.emacs.help Subject: Re: How do i say it in emacs lisp Date: Mon, 28 Nov 2016 10:21:00 +0100 Message-ID: <20161128092100.GA23484@tuxteam.de> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; x-action=pgp-signed Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1480324927 17043 195.159.176.226 (28 Nov 2016 09:22:07 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 28 Nov 2016 09:22:07 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) Cc: help-gnu-emacs@gnu.org To: Matthias Pfeifer Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Nov 28 10:22:00 2016 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cBI8N-0003GG-MT for geh-help-gnu-emacs@m.gmane.org; Mon, 28 Nov 2016 10:21:59 +0100 Original-Received: from localhost ([::1]:57467 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cBI8R-0007qv-69 for geh-help-gnu-emacs@m.gmane.org; Mon, 28 Nov 2016 04:22:03 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36982) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cBI7j-0007q8-6D for help-gnu-emacs@gnu.org; Mon, 28 Nov 2016 04:21:20 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cBI7e-00042j-Do for help-gnu-emacs@gnu.org; Mon, 28 Nov 2016 04:21:19 -0500 Original-Received: from mail.tuxteam.de ([5.199.139.25]:48003 helo=tomasium.tuxteam.de) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cBI7e-0003wl-8G for help-gnu-emacs@gnu.org; Mon, 28 Nov 2016 04:21:14 -0500 Original-Received: from tomas by tomasium.tuxteam.de with local (Exim 4.80) (envelope-from ) id 1cBI7Q-0006I8-SF; Mon, 28 Nov 2016 10:21:00 +0100 In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 5.199.139.25 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.help:111818 Archived-At: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Sun, Nov 27, 2016 at 09:46:49PM +0100, Matthias Pfeifer wrote: > Hi there, > > I want to say this in emacs lisp > > Whenever the buffer in the selected window > Is changed, do something in a certain other window (which displays a > certain well known buffer) > > Is this possible? How would it be done? Yes. Since your question is pretty unspecific, I'll assume you'd like to be pointed in a general direction. Here it goes: Emacs's way of extending functionality "whenever something happens" is typically called "hooks": you can insert a function of yours to be called whenever "something" happens. The hooks you are looking for are described in the Emacs Lisp manual (31.28, Change hooks [1]). There, you have to decide whether you want to be called before or after the text change happens (there are two aptly named hooks). To get the ball rolling, here's minimal code which complains at every change in a buffer: (add-hook 'after-change-functions (lambda (beg end oldlen) (message (format "Ouch: beg=%S end=%S oldlen=%S" beg end oldlen))) nil t) Insert it in a buffer in lisp mode (e.g. your *scratch* buffer, if your Emacs is set up in a "normal" way, type C-x C-e to get the hook function inseerted and watch the action whenever you modify the buffer. The "t" at the end sets the hook locally, i.e. only for the local buffer. Do come back if you have further questions! regards [1] Or online, at https://www.gnu.org/software/emacs/manual/html_node/elisp/Change-Hooks.html - -- tomás -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAlg79vwACgkQBcgs9XrR2kZofACfdhy4Lr6bB88PgToGEZr3Bcg1 La4Anij3GKm97u6y+FpadyBgV/HfZxEN =xwDi -----END PGP SIGNATURE-----