Implement the `org-table-electric-header-mode' minor mode
* lisp/org-table.el (org-table-electric-header-p): New option. (org-table-temp-header-line, org-table-electric-header-mode): New variables. (org-table-set-header-line-format) (org-table-electric-header-mode): New minor mode to display the table's current first row as the header line when this first row is not visible anymore. * doc/org-manual.org (Miscellaneous): Document `org-table-electric-header-mode'.
This commit is contained in:
parent
0f86a14af3
commit
b476ffd266
|
@ -1638,6 +1638,15 @@ you, configure the option ~org-table-auto-blank-field~.
|
|||
the same as the format used by Orgtbl radio tables, see [[*Translator
|
||||
functions]], for a detailed description.
|
||||
|
||||
- {{{kbd(M-x org-table-electric-header-mode)}}} ::
|
||||
|
||||
#+findex: org-table-electric-header-mode
|
||||
#+vindex: org-table-electric-header-p
|
||||
Turn on the display of the first data row of the table at point in
|
||||
the window header line when this first row is not visible anymore in
|
||||
the buffer. You can activate this minor mode by default by setting
|
||||
the option ~org-table-electric-header-p~ to ~t~.
|
||||
|
||||
** Column Width and Alignment
|
||||
:PROPERTIES:
|
||||
:DESCRIPTION: Overrule the automatic settings.
|
||||
|
|
|
@ -13,6 +13,13 @@ Please send Org bug reports to mailto:emacs-orgmode@gnu.org.
|
|||
* Version 9.4 (not yet released)
|
||||
** New features
|
||||
|
||||
*** New minor mode ~org-table-electric-header-mode~
|
||||
|
||||
Turn on the display of the first data row of the table at point in the
|
||||
window header line when this first row is not visible anymore in the
|
||||
buffer. You can activate this minor mode by default by setting the
|
||||
option ~org-table-electric-header-p~ to ~t~.
|
||||
|
||||
*** Property drawers before first headline, outline level 0
|
||||
|
||||
Property drawers will now work before first headline and Org mode is
|
||||
|
|
|
@ -164,6 +164,12 @@ table, obtained by prompting the user."
|
|||
:tag "Org Table Settings"
|
||||
:group 'org-table)
|
||||
|
||||
(defcustom org-table-electric-header-p nil
|
||||
"Activate `org-table-electric-header-mode' by default?"
|
||||
:type 'boolean
|
||||
:package-version "9.4"
|
||||
:group 'org-table)
|
||||
|
||||
(defcustom org-table-default-size "5x2"
|
||||
"The default size for newly created tables, Columns x Rows."
|
||||
:group 'org-table-settings
|
||||
|
@ -441,6 +447,42 @@ prevents it from hanging Emacs."
|
|||
:type 'integer
|
||||
:package-version '(Org . "8.3"))
|
||||
|
||||
|
||||
;;; Org table electric header minor mode
|
||||
(defvar org-table-temp-header-line nil)
|
||||
(defun org-table-set-header-line-format ()
|
||||
"Set the header of table at point as the `header-line-format'.
|
||||
Assume `org-table-temp-header-line' already stores the previously
|
||||
existing value of `header-line-format' we might want to restore."
|
||||
(if (org-at-table-p)
|
||||
(run-with-timer
|
||||
0 nil
|
||||
(lambda ()
|
||||
(let* ((beg (org-table-begin))
|
||||
(tbeg (if (save-excursion (goto-char beg) (org-at-table-hline-p))
|
||||
(save-excursion (goto-char beg) (move-beginning-of-line 2) (point))
|
||||
beg)))
|
||||
(if (< tbeg (save-excursion (move-to-window-line 0) (point)))
|
||||
(setq header-line-format
|
||||
(concat (propertize " " 'display '(space :width left-fringe))
|
||||
(buffer-substring
|
||||
tbeg (+ tbeg (- (point-at-eol) (point-at-bol))))))
|
||||
(setq header-line-format org-table-temp-header-line)))))
|
||||
(setq header-line-format org-table-temp-header-line)))
|
||||
|
||||
(defvar org-table-electric-header-mode nil)
|
||||
(define-minor-mode org-table-electric-header-mode
|
||||
"Display the first row of the table at point in the header line."
|
||||
:init-value org-table-electric-header-p
|
||||
:global nil
|
||||
:variable org-table-electric-header-mode
|
||||
:group 'org-table
|
||||
(if org-table-electric-header-mode
|
||||
(progn (setq org-table-temp-header-line header-line-format)
|
||||
(add-hook 'post-command-hook 'org-table-set-header-line-format))
|
||||
(remove-hook 'post-command-hook 'org-table-set-header-line-format)
|
||||
(setq header-line-format org-table-temp-header-line)))
|
||||
|
||||
|
||||
;;; Regexps Constants
|
||||
|
||||
|
|
Loading…
Reference in New Issue