help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: org-mode with a custom binding on S-Up and no shift-select


From: Vagn Johansen
Subject: Re: org-mode with a custom binding on S-Up and no shift-select
Date: Fri, 22 May 2009 11:23:43 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (darwin)

Alain Ketterlin <alain@dpt-info.u-strasbg.fr> writes:

> Hello,
>
> I've just started using org-mode and have a small problem with <S-up>
> and <S-down>. I don't use shift-select-mode. My .emacs has:
>
> (global-set-key (kbd "S-<down>") `(lambda ()
>                                     (interactive)
>                                     (scroll-up 1)))

I have the same bindings .. well it is (scroll-up 2) in my case.

> and similar for <S-up>. (BTW, is interactive of any use here? I copied
> this somewhere, my elisp skills are almost non-existent.)
>
> Org-mode has special use for <S-up> and <S-down>. I would like to keep
> my own bindings, except on timestamps. 

And the same problem. If often add priorities to tasks (#A,..) when I
want to scroll down.


I just cooked up the code below. I sets up the shift up/down to
scrolling. IF in org-mode and NOT at the beginning of the line then
the org shift functions are called.


(require 'org)

(global-set-key [S-up] 'vj-scroll-down-hook)
(global-set-key [S-down] 'vj-scroll-up-hook)

(defun vj-org-shift-keys-setup ()
  (interactive)
  (local-set-key [S-up] 'vj-scroll-down)
  (local-set-key [S-down] 'vj-scroll-up))


(add-hook 'org-mode-hook  'vj-org-shift-keys-setup)

(defun vj-scroll-up (&optional arg)
  "Vj scroll-up."
  (interactive)
  (if (and (equal major-mode 'org-mode) (not (bolp)))
    ;; In org-mode and not at beginning of line
    (org-shiftup arg)
    ;; else
    (scroll-up 2)))


(defun vj-scroll-down (&optional arg)
  "Vj scroll-down."
  (interactive)
  (if (and (equal major-mode 'org-mode) (not (bolp)))
    ;; In org-mode and not at beginning of line
    (org-shiftdown arg)
    ;; else
    (scroll-down 2)))

-- 
Vagn Johansen


reply via email to

[Prev in Thread] Current Thread [Next in Thread]