From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: York Zhao Newsgroups: gmane.emacs.help Subject: How to add property for a buffer object Date: Wed, 12 Sep 2012 11:30:50 -0400 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1347463873 25531 80.91.229.3 (12 Sep 2012 15:31:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 12 Sep 2012 15:31:13 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Sep 12 17:31:17 2012 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 1TBouE-0007QD-L4 for geh-help-gnu-emacs@m.gmane.org; Wed, 12 Sep 2012 17:31:10 +0200 Original-Received: from localhost ([::1]:49469 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TBouB-0007Sn-0n for geh-help-gnu-emacs@m.gmane.org; Wed, 12 Sep 2012 11:31:07 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:39142) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TBou1-0007NA-Ft for help-gnu-emacs@gnu.org; Wed, 12 Sep 2012 11:31:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TBotv-0007eQ-FV for help-gnu-emacs@gnu.org; Wed, 12 Sep 2012 11:30:57 -0400 Original-Received: from mail-vb0-f41.google.com ([209.85.212.41]:49404) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TBotv-0007e3-Be for help-gnu-emacs@gnu.org; Wed, 12 Sep 2012 11:30:51 -0400 Original-Received: by vbkv13 with SMTP id v13so2770805vbk.0 for ; Wed, 12 Sep 2012 08:30:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=xN4sdQNS2I8xK9tcytcx5dsVDlgTvuMaxah0v0Ct5P4=; b=d+CI6avyd4EYSvG8dP7DCRtLsS1MZJGmEmbN4+wdiyyjOaSJ5O6GukKdDblhgolhFx JgFNBZ01FHcLaCsUTiVeut5DSfoOKxFB3f29nDHahQIwvzZUrv47j8ctR9pwrx4i81aU K8umEszVJOTR01Py+3unX80zmZ5Tas0CAWrt3SmG1iqwR3J2cd8u3dRXCGG2rGyMhhLE VOVMW3442RUq2+gUmfl/E2VVM7kW1J+lB1kZmpMJXaWWGW3n6V4hCZ5v4KanZUg+nitb 4ugsvbvf26J38AIgn3DBnNGsmJnKPhddqc5o2V5Ur4pEU8PI9IkzoxiJgX2CSpp5zBvm 9RrQ== Original-Received: by 10.58.80.66 with SMTP id p2mr31753231vex.16.1347463850570; Wed, 12 Sep 2012 08:30:50 -0700 (PDT) Original-Received: by 10.52.185.194 with HTTP; Wed, 12 Sep 2012 08:30:50 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.212.41 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:86732 Archived-At: I like longlines-mode and refill-mode, but unfortunately there are always times I have to turn them off. Therefor, I binded a key to toggle the `refill-mode'. But I also want to toggle the `longlines-mode', however, I want to use only one key to toggle either `refill-mode', or `longlines-mode'. My thought is to add a property to current buffer so that the toggle command knows which one to toggle. The problem is that the `get' and `put' function require a symbol not a buffer object. So, is there any way to "get" and "put" property on a buffer? Or, is there any other solution to have one function toggle either `longlines-mode' or 'refill-mode'? Here is my function (not working) for your reference. (defun york/toggle-longlines-or-refill-mode () (interactive) (if (null (get (current-buffer) 'longlines-mode-turned-off-p)) (refill-mode) (put (current-buffer) 'longlines-mode-turned-off-p (if (eq (get (current-buffer) 'longlines-mode-turned-off-p) 'Yes) 'No 'Yes)) (longlines-mode 1))) Thanks in advance York