From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.help Subject: RE: How to add property for a buffer object Date: Wed, 12 Sep 2012 10:10:57 -0700 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1347469876 17875 80.91.229.3 (12 Sep 2012 17:11:16 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 12 Sep 2012 17:11:16 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: "'York Zhao'" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Sep 12 19:11:20 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 1TBqT7-0001Is-Qw for geh-help-gnu-emacs@m.gmane.org; Wed, 12 Sep 2012 19:11:18 +0200 Original-Received: from localhost ([::1]:57150 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TBqT4-00016s-3J for geh-help-gnu-emacs@m.gmane.org; Wed, 12 Sep 2012 13:11:14 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:59560) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TBqSv-00016l-0y for help-gnu-emacs@gnu.org; Wed, 12 Sep 2012 13:11:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TBqSt-00087o-Qb for help-gnu-emacs@gnu.org; Wed, 12 Sep 2012 13:11:04 -0400 Original-Received: from acsinet15.oracle.com ([141.146.126.227]:43807) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TBqSt-00087T-Jm for help-gnu-emacs@gnu.org; Wed, 12 Sep 2012 13:11:03 -0400 Original-Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by acsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id q8CHB0VA016698 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 12 Sep 2012 17:11:00 GMT Original-Received: from acsmt357.oracle.com (acsmt357.oracle.com [141.146.40.157]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id q8CHAxbu003273 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 12 Sep 2012 17:10:59 GMT Original-Received: from abhmt120.oracle.com (abhmt120.oracle.com [141.146.116.72]) by acsmt357.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id q8CHAxlF026907; Wed, 12 Sep 2012 12:10:59 -0500 Original-Received: from dradamslap1 (/130.35.178.248) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 12 Sep 2012 10:10:59 -0700 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: Thread-Index: Ac2RBLU6uNHP1+5oS2u384y40QiogAAAGhJg X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-Source-IP: acsinet21.oracle.com [141.146.126.237] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 1) X-Received-From: 141.146.126.227 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:86735 Archived-At: > > You can use `get' and `put' on the symbol that is the value > > of variable `major-mode'. > > I don't think this would help because I need to attach > something to the buffer, not all the buffers in the major-mode. Or you could keep track of which buffers in the mode you care about this way. IOW, work with a list of buffers instead of setting and getting a property for each of those buffers. > > Or you can simply make some variable buffer-local for a given mode. > > Yes, I think this would work, but I then have to create a > variable for this, have no idea why Emacs doesn't allow > assigning property to the buffer object itself, just like > assigning property to a symbol. Emacs Lisp has: * symbol properties for symbols * text properties for buffer text and strings * overlay properties for overlays (which apply to buffers, and by extension to a buffer's window) * button properties for buttons That's about it, IIRC. But usually other Lisp objects that you might want to assign a property to are somehow associated with one or more of those things, so you can just assign the property to the associated thing (e.g., to a symbol). For a buffer, as an alternative to a buffer-local variable or a list of affected buffers, you could put a property on a symbol whose name is the same as the buffer name. Or you could put a text property on a string that is `string=' to the buffer name. Or if you can depend on some of the buffer text remaining the same, you could put a text property on some buffer position (e.g. (point-min)). > > Test something specific to the buffer or its mode (see above). > > Or just use a prefix arg (and test that). > > I'm sure this would work, but I'm still not happy with having > to do it this way. > Maybe the ultimate solution is to fix the `refill-mode' itself > so that I can alway have it turned on (tired of having to hit "M-q" almost > all the time). I don't use `refill-mode', but the doc string says it is a (buffer-local) minor mode. (I guess there is no globalized equivalent, but you could define one if you needed it.) > The major problem with `refill-mode' however, is that it intercepts > the "fill-function" therefor was not able to handle refilling > properly in org-mode, especially, it would mess up org tables. > Also, if you have `refill-mode' turned on, you will never be able > to break a paragraph into two by hitting while > the point is in the middle of the paragraph. Sounds like there should be a bug report or enhancement request in there somewhere. ;-) `M-x report-emacs-bug'. > On the other hand, the `auto-fill-mode' never "auto-fill" when > inserting text in the middle of a line, because of this, I have > to hit "M-q" all the time. Do you know of any other way > to really handle "auto-fill" property? No, I'm probably not the right one to ask. But hopefully someone else will have a suggestion. I use `M-q' and `C-M-q' (e.g. in Lisp code). There are also other fill commands, which operate on multiple paragraphs in the region: `fill-region', `fill-individual-paragraphs', and `fill-nonuniform-paragraphs'. When one of them does what you want, you might be able to use it in place of several uses of `M-q'.