From 7244bbfdbcbef29054a1f6035a6acc1983a23bd0 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sat, 1 Nov 2014 15:48:15 +0000 Subject: Major-mode for navigating question list. --- stack-navigation-mode.el | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 stack-navigation-mode.el (limited to 'stack-navigation-mode.el') diff --git a/stack-navigation-mode.el b/stack-navigation-mode.el new file mode 100644 index 0000000..e4c6bb9 --- /dev/null +++ b/stack-navigation-mode.el @@ -0,0 +1,52 @@ +;;; stack-navigation-mode.el --- Major-mode for navigating questions list. -*- lexical-binding: t; -*- + +;; Copyright (C) 2014 Artur Malabarba + +;; Author: Artur Malabarba +;; Keywords: help, hypermedia, mail, news, tools + + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: + +;;; Code: + + +;;; Requirements +(define-derived-mode stack-navigation-mode org-mode "Stack-Nav") + +(mapc + (lambda (x) (define-key stack-navigation-mode-map + (car x) (cadr x))) + '(("j" stack-navigation-mode-next-question) + ("k" stack-navigation-mode-previous-question) + ("n" outline-next-visible-heading) + ("p" outline-previous-visible-heading) + )) + +(defun stack-navigation-mode-previous-question (n) + "Hide this question, move to previous one, display it." + (interactive "p") + (stack-navigation-mode-next-question (- n))) + +(defun stack-navigation-mode-next-question (n) + "Hide this question, move to next one, display it." + (interactive "p") + (org-global-cycle 1) + (org-forward-heading-same-level n 'invis-ok) + (org-show-subtree)) + +(provide 'stack-navigation-mode) +;;; stack-navigation-mode.el ends here -- cgit v1.2.3