From: Andreas Gerler Date: Fri, 31 Jan 2020 16:55:21 +0000 (+0100) Subject: update org-sticky-header X-Git-Url: http://git.bundesbrandschatzamt.de/?a=commitdiff_plain;h=5f62f9d66c29926f95a360d58d38f627ae8c6dc2;p=emacsconfig.git update org-sticky-header --- diff --git a/bba.org b/bba.org index a83c4fdb..a239ceaf 100644 --- a/bba.org +++ b/bba.org @@ -2065,7 +2065,7 @@ file. [2017-04-26 Wed 13:09] #+BEGIN_SRC emacs-lisp :tangle yes - (add-to-list 'load-path "~/.emacs.d/elpa/org-sticky-header-20190406.2313" t) + (add-to-list 'load-path "~/.emacs.d/elpa/org-sticky-header-20191117.549" t) (add-hook 'org-mode-hook (lambda ()(org-sticky-header-mode 1)) ) diff --git a/elpa/org-sticky-header-20190406.2313/org-sticky-header-autoloads.el b/elpa/org-sticky-header-20190406.2313/org-sticky-header-autoloads.el deleted file mode 100644 index 23e08fdb..00000000 --- a/elpa/org-sticky-header-20190406.2313/org-sticky-header-autoloads.el +++ /dev/null @@ -1,24 +0,0 @@ -;;; org-sticky-header-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path)))) - -;;;### (autoloads nil "org-sticky-header" "org-sticky-header.el" -;;;;;; (23994 46394 422834 160000)) -;;; Generated autoloads from org-sticky-header.el - -(autoload 'org-sticky-header-mode "org-sticky-header" "\ -Minor mode to show the current Org heading in the header line. -With prefix argument ARG, turn on if positive, otherwise off. -Return non-nil if the minor mode is enabled. - -\(fn &optional ARG)" t nil) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; org-sticky-header-autoloads.el ends here diff --git a/elpa/org-sticky-header-20190406.2313/org-sticky-header-pkg.el b/elpa/org-sticky-header-20190406.2313/org-sticky-header-pkg.el deleted file mode 100644 index c6ac0107..00000000 --- a/elpa/org-sticky-header-20190406.2313/org-sticky-header-pkg.el +++ /dev/null @@ -1,2 +0,0 @@ -;;; -*- no-byte-compile: t -*- -(define-package "org-sticky-header" "20190406.2313" "Show off-screen Org heading at top of window" '((emacs "24.4") (org "8.3.5")) :commit "32c13a56a78a4de239010031fea4b9583bac2512" :keywords '("hypermedia" "outlines" "org") :authors '(("Adam Porter" . "adam@alphapapa.net")) :maintainer '("Adam Porter" . "adam@alphapapa.net") :url "http://github.com/alphapapa/org-sticky-header") diff --git a/elpa/org-sticky-header-20190406.2313/org-sticky-header.el b/elpa/org-sticky-header-20190406.2313/org-sticky-header.el deleted file mode 100644 index 856bd81c..00000000 --- a/elpa/org-sticky-header-20190406.2313/org-sticky-header.el +++ /dev/null @@ -1,208 +0,0 @@ -;;; org-sticky-header.el --- Show off-screen Org heading at top of window -*- lexical-binding: t -*- - -;; Author: Adam Porter -;; Url: http://github.com/alphapapa/org-sticky-header -;; Package-Version: 20190406.2313 -;; Version: 1.0.1 -;; Package-Requires: ((emacs "24.4") (org "8.3.5")) -;; Keywords: hypermedia, outlines, Org - -;;; Commentary: - -;; This package displays in the header-line the Org heading for the -;; node that's at the top of the window. This way, if the heading for -;; the text at the top of the window is beyond the top of the window, -;; you don't forget which heading the text belongs to. - -;; The code is very simple and is based on `semantic-stickyfunc-mode'. - -;;; Installation: - -;; Install from MELPA and run `org-sticky-header-mode'. - -;; To install manually, put this file in your `load-path', require -;; `org-sticky-header' in your init file, and run the same command. - -;; You probably want to add `org-sticky-header-mode' to your `org-mode-hook'. - -;; By default, the line will be indented like a real headline. To -;; change this, configure `org-sticky-header-prefix'. - -;;; License: - -;; 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 . - -;;; Code: - -;;;; Requirements - -(require 'cl-lib) -(require 'org) - -;;;; Variables - -(defvar org-sticky-header-old-hlf nil - "Value of the header line when entering org-sticky-header mode.") - -(defvar-local org-sticky-header-stickyline nil - "Value of header line") -(put 'org-sticky-header-stickyline 'risky-local-variable t) - -(defconst org-sticky-header-header-line-format - '(:eval (progn - (setq org-sticky-header-stickyline (org-sticky-header--fetch-stickyline)) - (list - (propertize " " 'display '((space :align-to 0))) - 'org-sticky-header-stickyline))) - "The header line format used by stickyfunc mode.") - -(defgroup org-sticky-header nil - "Options for `org-sticky-header-mode'." - :group 'org) - -(defcustom org-sticky-header-full-path nil - "Show the full outline path." - :type '(radio (const :tag "Show only current heading" nil) - (const :tag "Show full outline path to current heading" full) - (const :tag "Show full outline path, but reversed so current heading is first" reversed))) - -(defcustom org-sticky-header-always-show-header t - "Show the header even when the top line of the buffer is a heading. -When this is on, and the top line of the buffer is a heading, -you'll see the heading shown twice: once in the header and once -in the buffer. But since the header can look different than the -heading (i.e. it can show the full path), it shouldn't -necessarily disappear. If you use full-path display, you probably -want this on, but if you only display the current heading, you -might prefer to turn it off. " - :type 'boolean) - -(defcustom org-sticky-header-prefix 'org-sticky-header--indent-prefix - "Prefix to display before heading in header line. -`org-indent-mode' users should use the default function. Custom -functions will be run with point on a heading." - :type '(choice (function-item :tag "Like real headline" org-sticky-header--indent-prefix) - (string :tag "Custom string" :value " ") - (function :tag "Custom function which returns a string") - (const :tag "None" nil))) - -(defcustom org-sticky-header-outline-path-separator "/" - "String displayed between elements of outline paths." - :type 'string) - -(defcustom org-sticky-header-outline-path-reversed-separator "\\" - "String displayed between elements of reversed outline paths." - :type 'string) - -(defcustom org-sticky-header-heading-star "*" - "String to show before heading. -By default, show an asterisk, like in an Org buffer. Changing -this to something else may help distinguish the header line from -headings in the buffer when `org-sticky-header-always-show-header' -is enabled." - :type 'string) - -;;;; Functions - -(defun org-sticky-header--fetch-stickyline () - "Return string of Org heading or outline path for display in header line." - (org-with-wide-buffer - (goto-char (window-start)) - (unless (org-before-first-heading-p) - ;; No non-header lines above top displayed header - (when (or org-sticky-header-always-show-header - (not (org-at-heading-p))) - ;; Header should be shown - (when (fboundp 'org-inlinetask-in-task-p) - ;; Skip inline tasks - (while (and (org-back-to-heading) - (org-inlinetask-in-task-p)) - (forward-line -1))) - (cond - ;; FIXME: Convert cond back to pcase, but one compatible with Emacs 24 - ((null org-sticky-header-full-path) - (concat (org-sticky-header--get-prefix) - (org-get-heading t t))) - ((eq org-sticky-header-full-path 'full) - (concat (org-sticky-header--get-prefix) - (org-format-outline-path (org-get-outline-path t) - (window-width) - nil org-sticky-header-outline-path-separator))) - ((eq org-sticky-header-full-path 'reversed) - (let ((s (concat (org-sticky-header--get-prefix) - (mapconcat 'identity - (nreverse (org-split-string (org-format-outline-path (org-get-outline-path t) - 1000 nil "") - "")) - org-sticky-header-outline-path-reversed-separator)))) - (if (> (length s) (window-width)) - (concat (substring s 0 (- (window-width) 2)) - "..") - s))) - (t nil)))))) - -(defun org-sticky-header--get-prefix () - "Return prefix string depending on value of `org-sticky-header-prefix'." - (cl-typecase org-sticky-header-prefix - (function (funcall org-sticky-header-prefix)) - (string org-sticky-header-prefix) - (nil nil))) - -(defun org-sticky-header--indent-prefix () - "Return indentation prefix for heading at point. -This will do the right thing both with and without `org-indent-mode'." - ;; Modelled after `org-indent-set-line-properties' - (let* ((level (org-current-level)) - (indent-mode (bound-and-true-p org-indent-mode)) - (npre (if (<= level 1) 0 - (+ (if indent-mode - (* (1- org-indent-indentation-per-level) - (1- level)) - 0) - level -1))) - (prefix (concat (make-string npre (if indent-mode ?\ ?*)) org-sticky-header-heading-star " "))) - (org-add-props prefix nil 'face - (if org-cycle-level-faces - (setq org-f (nth (% (1- level) org-n-level-faces) org-level-faces)) - (setq org-f (nth (1- (min level org-n-level-faces)) org-level-faces)))))) - -;;;; Minor mode - -;;;###autoload -(define-minor-mode org-sticky-header-mode - "Minor mode to show the current Org heading in the header line. -With prefix argument ARG, turn on if positive, otherwise off. -Return non-nil if the minor mode is enabled." - :group 'org - (if org-sticky-header-mode - (progn - (when (and (local-variable-p 'header-line-format (current-buffer)) - (not (eq header-line-format org-sticky-header-header-line-format))) - ;; Save previous buffer local value of header line format. - (set (make-local-variable 'org-sticky-header-old-hlf) - header-line-format)) - ;; Enable the mode - (setq header-line-format org-sticky-header-header-line-format)) - ;; Disable mode - (when (eq header-line-format org-sticky-header-header-line-format) - ;; Restore previous buffer local value of header line format if - ;; the current one is the sticky func one. - (kill-local-variable 'header-line-format) - (when (local-variable-p 'org-sticky-header-old-hlf (current-buffer)) - (setq header-line-format org-sticky-header-old-hlf) - (kill-local-variable 'org-sticky-header-old-hlf))))) - -(provide 'org-sticky-header) - -;;; org-sticky-header.el ends here diff --git a/elpa/org-sticky-header-20191117.549/org-sticky-header-autoloads.el b/elpa/org-sticky-header-20191117.549/org-sticky-header-autoloads.el new file mode 100644 index 00000000..c960239f --- /dev/null +++ b/elpa/org-sticky-header-20191117.549/org-sticky-header-autoloads.el @@ -0,0 +1,30 @@ +;;; org-sticky-header-autoloads.el --- automatically extracted autoloads +;; +;;; Code: + +(add-to-list 'load-path (directory-file-name + (or (file-name-directory #$) (car load-path)))) + + +;;;### (autoloads nil "org-sticky-header" "org-sticky-header.el" +;;;;;; (0 0 0 0)) +;;; Generated autoloads from org-sticky-header.el + +(autoload 'org-sticky-header-mode "org-sticky-header" "\ +Minor mode to show the current Org heading in the header line. +With prefix argument ARG, turn on if positive, otherwise off. +Return non-nil if the minor mode is enabled. + +\(fn &optional ARG)" t nil) + +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "org-sticky-header" '("org-sticky-header-"))) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; coding: utf-8 +;; End: +;;; org-sticky-header-autoloads.el ends here diff --git a/elpa/org-sticky-header-20191117.549/org-sticky-header-pkg.el b/elpa/org-sticky-header-20191117.549/org-sticky-header-pkg.el new file mode 100644 index 00000000..c6889c69 --- /dev/null +++ b/elpa/org-sticky-header-20191117.549/org-sticky-header-pkg.el @@ -0,0 +1,2 @@ +;;; -*- no-byte-compile: t -*- +(define-package "org-sticky-header" "20191117.549" "Show off-screen Org heading at top of window" '((emacs "24.4") (org "8.3.5")) :commit "1053ebdeb3bd14fc8d4538643532efb86d18b73c" :keywords '("hypermedia" "outlines" "org") :authors '(("Adam Porter" . "adam@alphapapa.net")) :maintainer '("Adam Porter" . "adam@alphapapa.net") :url "http://github.com/alphapapa/org-sticky-header") diff --git a/elpa/org-sticky-header-20191117.549/org-sticky-header.el b/elpa/org-sticky-header-20191117.549/org-sticky-header.el new file mode 100644 index 00000000..04e6a4d4 --- /dev/null +++ b/elpa/org-sticky-header-20191117.549/org-sticky-header.el @@ -0,0 +1,224 @@ +;;; org-sticky-header.el --- Show off-screen Org heading at top of window -*- lexical-binding: t -*- + +;; Author: Adam Porter +;; Url: http://github.com/alphapapa/org-sticky-header +;; Package-Version: 20191117.549 +;; Version: 1.1-pre +;; Package-Requires: ((emacs "24.4") (org "8.3.5")) +;; Keywords: hypermedia, outlines, Org + +;;; Commentary: + +;; This package displays in the header-line the Org heading for the +;; node that's at the top of the window. This way, if the heading for +;; the text at the top of the window is beyond the top of the window, +;; you don't forget which heading the text belongs to. + +;; The code is very simple and is based on `semantic-stickyfunc-mode'. + +;;; Installation: + +;; Install from MELPA and run `org-sticky-header-mode'. + +;; To install manually, put this file in your `load-path', require +;; `org-sticky-header' in your init file, and run the same command. + +;; You probably want to add `org-sticky-header-mode' to your `org-mode-hook'. + +;; By default, the line will be indented like a real headline. To +;; change this, configure `org-sticky-header-prefix'. + +;;; License: + +;; 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 . + +;;; Code: + +;;;; Requirements + +(require 'cl-lib) +(require 'org) + +;;;; Variables + +(defvar org-sticky-header-old-hlf nil + "Value of the header line when entering org-sticky-header mode.") + +(defvar-local org-sticky-header-stickyline nil + "Value of header line") +(put 'org-sticky-header-stickyline 'risky-local-variable t) + +(defvar org-sticky-header-keymap + (let ((map (make-sparse-keymap))) + (define-key map (kbd " ") #'org-sticky-header-goto-heading) + map) + "Keymap used in header line.") + +(defconst org-sticky-header-header-line-format + '(:eval (progn + (setq org-sticky-header-stickyline + (propertize (org-sticky-header--fetch-stickyline) + 'keymap org-sticky-header-keymap)) + (list + (propertize " " 'display '((space :align-to 0))) + 'org-sticky-header-stickyline))) + "The header line format used by stickyfunc mode.") + +(defgroup org-sticky-header nil + "Options for `org-sticky-header-mode'." + :group 'org) + +(defcustom org-sticky-header-full-path nil + "Show the full outline path." + :type '(radio (const :tag "Show only current heading" nil) + (const :tag "Show full outline path to current heading" full) + (const :tag "Show full outline path, but reversed so current heading is first" reversed))) + +(defcustom org-sticky-header-always-show-header t + "Show the header even when the top line of the buffer is a heading. +When this is on, and the top line of the buffer is a heading, +you'll see the heading shown twice: once in the header and once +in the buffer. But since the header can look different than the +heading (i.e. it can show the full path), it shouldn't +necessarily disappear. If you use full-path display, you probably +want this on, but if you only display the current heading, you +might prefer to turn it off. " + :type 'boolean) + +(defcustom org-sticky-header-prefix 'org-sticky-header--indent-prefix + "Prefix to display before heading in header line. +`org-indent-mode' users should use the default function. Custom +functions will be run with point on a heading." + :type '(choice (function-item :tag "Like real headline" org-sticky-header--indent-prefix) + (string :tag "Custom string" :value " ") + (function :tag "Custom function which returns a string") + (const :tag "None" nil))) + +(defcustom org-sticky-header-outline-path-separator "/" + "String displayed between elements of outline paths." + :type 'string) + +(defcustom org-sticky-header-outline-path-reversed-separator "\\" + "String displayed between elements of reversed outline paths." + :type 'string) + +(defcustom org-sticky-header-heading-star "*" + "String to show before heading. +By default, show an asterisk, like in an Org buffer. Changing +this to something else may help distinguish the header line from +headings in the buffer when `org-sticky-header-always-show-header' +is enabled." + :type 'string) + +;;;; Functions + +(defun org-sticky-header-goto-heading (event) + "Go to heading displayed in sticky header (for click event EVENT)." + (interactive "e") + (with-selected-window (posn-window (event-start event)) + (goto-char (window-start)) + (unless (org-before-first-heading-p) + (org-back-to-heading)))) + +(defun org-sticky-header--fetch-stickyline () + "Return string of Org heading or outline path for display in header line." + (org-with-wide-buffer + (goto-char (window-start)) + (unless (org-before-first-heading-p) + ;; No non-header lines above top displayed header + (when (or org-sticky-header-always-show-header + (not (org-at-heading-p))) + ;; Header should be shown + (when (fboundp 'org-inlinetask-in-task-p) + ;; Skip inline tasks + (while (and (org-back-to-heading) + (org-inlinetask-in-task-p)) + (forward-line -1))) + (cond + ;; FIXME: Convert cond back to pcase, but one compatible with Emacs 24 + ((null org-sticky-header-full-path) + (concat (org-sticky-header--get-prefix) + (org-get-heading t t))) + ((eq org-sticky-header-full-path 'full) + (concat (org-sticky-header--get-prefix) + (org-format-outline-path (org-get-outline-path t) + (window-width) + nil org-sticky-header-outline-path-separator))) + ((eq org-sticky-header-full-path 'reversed) + (let ((s (concat (org-sticky-header--get-prefix) + (mapconcat 'identity + (nreverse (org-split-string (org-format-outline-path (org-get-outline-path t) + 1000 nil "") + "")) + org-sticky-header-outline-path-reversed-separator)))) + (if (> (length s) (window-width)) + (concat (substring s 0 (- (window-width) 2)) + "..") + s))) + (t nil)))))) + +(defun org-sticky-header--get-prefix () + "Return prefix string depending on value of `org-sticky-header-prefix'." + (cl-typecase org-sticky-header-prefix + (function (funcall org-sticky-header-prefix)) + (string org-sticky-header-prefix) + (nil nil))) + +(defun org-sticky-header--indent-prefix () + "Return indentation prefix for heading at point. +This will do the right thing both with and without `org-indent-mode'." + ;; Modelled after `org-indent-set-line-properties' + (let* ((level (org-current-level)) + (indent-mode (bound-and-true-p org-indent-mode)) + (npre (if (<= level 1) 0 + (+ (if indent-mode + (* (1- org-indent-indentation-per-level) + (1- level)) + 0) + level -1))) + (prefix (concat (make-string npre (if indent-mode ?\ ?*)) org-sticky-header-heading-star " "))) + (org-add-props prefix nil 'face + (if org-cycle-level-faces + (setq org-f (nth (% (1- level) org-n-level-faces) org-level-faces)) + (setq org-f (nth (1- (min level org-n-level-faces)) org-level-faces)))))) + +;;;; Minor mode + +;;;###autoload +(define-minor-mode org-sticky-header-mode + "Minor mode to show the current Org heading in the header line. +With prefix argument ARG, turn on if positive, otherwise off. +Return non-nil if the minor mode is enabled." + :group 'org + (if org-sticky-header-mode + (progn + (when (and (local-variable-p 'header-line-format (current-buffer)) + (not (eq header-line-format org-sticky-header-header-line-format))) + ;; Save previous buffer local value of header line format. + (set (make-local-variable 'org-sticky-header-old-hlf) + header-line-format)) + ;; Enable the mode + (setq header-line-format org-sticky-header-header-line-format)) + ;; Disable mode + (when (eq header-line-format org-sticky-header-header-line-format) + ;; Restore previous buffer local value of header line format if + ;; the current one is the sticky func one. + (kill-local-variable 'header-line-format) + (when (local-variable-p 'org-sticky-header-old-hlf (current-buffer)) + (setq header-line-format org-sticky-header-old-hlf) + (kill-local-variable 'org-sticky-header-old-hlf))))) + +(provide 'org-sticky-header) + +;;; org-sticky-header.el ends here