From: "Drew Adams" <drew.adams@oracle.com>
To: "'York Zhao'" <gtdplatform@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: RE: How to add property for a buffer object
Date: Wed, 12 Sep 2012 10:10:57 -0700 [thread overview]
Message-ID: <A4F683746F804B759BFDFD9AB44962A5@us.oracle.com> (raw)
In-Reply-To: <CAD3zm21LXrxZk-yEOZ-ZkZUK3=J5GGFwJkGD6roN-KLtksgLmA@mail.gmail.com>
> > 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 <RET> 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'.
next prev parent reply other threads:[~2012-09-12 17:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-12 15:30 How to add property for a buffer object York Zhao
2012-09-12 15:58 ` Drew Adams
2012-09-12 16:36 ` York Zhao
2012-09-12 17:10 ` Drew Adams [this message]
2012-09-12 18:49 ` York Zhao
2012-09-12 20:55 ` Drew Adams
2012-09-13 1:43 ` York Zhao
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=A4F683746F804B759BFDFD9AB44962A5@us.oracle.com \
--to=drew.adams@oracle.com \
--cc=gtdplatform@gmail.com \
--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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.