[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
How to add property for a buffer object
From: |
York Zhao |
Subject: |
How to add property for a buffer object |
Date: |
Wed, 12 Sep 2012 11:30:50 -0400 |
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
- How to add property for a buffer object,
York Zhao <=