all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to add property for a buffer object
@ 2012-09-12 15:30 York Zhao
  2012-09-12 15:58 ` Drew Adams
  0 siblings, 1 reply; 7+ messages in thread
From: York Zhao @ 2012-09-12 15:30 UTC (permalink / raw)
  To: help-gnu-emacs

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



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-09-13  1:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2012-09-12 18:49       ` York Zhao
2012-09-12 20:55         ` Drew Adams
2012-09-13  1:43           ` York Zhao

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.