From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id WCjKGdOJ7mGDxAAAgWs5BA (envelope-from ) for ; Mon, 24 Jan 2022 12:13:23 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id 2GMbF9OJ7mEWYwAA9RJhRA (envelope-from ) for ; Mon, 24 Jan 2022 12:13:23 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id A93043D9AB for ; Mon, 24 Jan 2022 12:13:22 +0100 (CET) Received: from localhost ([::1]:36450 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nBxHl-000706-KG for larch@yhetil.org; Mon, 24 Jan 2022 06:13:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57002) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nBxGt-0006yG-N7 for emacs-orgmode@gnu.org; Mon, 24 Jan 2022 06:12:28 -0500 Received: from [2a00:f10:305:0:1c00:d8ff:fe00:461] (port=34371 helo=se08.route25.eu) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nBxGp-0007Ot-FC for emacs-orgmode@gnu.org; Mon, 24 Jan 2022 06:12:27 -0500 Date: Mon, 24 Jan 2022 12:11:40 +0100 From: Russell Adams To: emacs-orgmode@gnu.org Subject: Re: Read only org view mode Message-ID: Mail-Followup-To: emacs-orgmode@gnu.org References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Originating-IP: 2a00:f10:400:2:446:66ff:fe00:2ce X-SpamExperts-Domain: out.pcextreme.nl X-SpamExperts-Username: 2a00:f10:400:2:446:66ff:fe00:2ce X-SpamExperts-Outgoing-Class: ham X-SpamExperts-Outgoing-Evidence: Combined (0.15) X-Recommended-Action: accept X-Filter-ID: Pt3MvcO5N4iKaDQ5O6lkdGlMVN6RH8bjRMzItlySaT9WLQux0N3HQm8ltz8rnu+BPUtbdvnXkggZ 3YnVId/Y5jcf0yeVQAvfjHznO7+bT5xiExUbNqvmdkLSOzf1W2Y3z8hkeSqZT0W1YMl0fRDa99cV PSoHm0W/3adFfiYl2ns2bmdJlC9VsNWzootikMaN/T4GcPvCLvSpAEEGy7kYxsD3QRUnhlexiXT3 xXuXeIhevFP+kOiMW3ZJfjMJYMEj+gaXrHkgRC7/tI3CjXmVyrr7O2uMLAJZAiWkUTu8kCbHh0cQ L0Ci0sRm4Wh/iZxm6GtiR/ZS57IrkuRfCYlnnsztdQUSqk/AeLi65+4s/LrywTM2yEHEhvC9Izsy /NENTMQ3Kg3hL2oXz5A5E5R/dS4GkJ5hfB+qWugfDEytZYoACfRtBjLzEjgIZNLWhI/Mshn3T8Ox KyIrAogwLlirll+u0Sc2bgjgy6NE5WzPnrJ1fJyKyenPq733oZ8bAyJmHQrtppYmxMktfUX7kfB+ UdezYqxGMqsKjARq8PBC4qgxMmglBiLsgrvXOb7qEGUwgxHIagHkgJmlqPNWnLI1oovhSJcbnX/H QqL/X9rNCJCc6iESJvKm1NV8gkr+Wu8ScVDXinOVyuIpITQ9z3M3DKRYyu3V3HFYBcnRP4AYwep/ j5YYrbryQC7BeYbD8SZG5oyPdqvJbdilYQ3bQuUf0a2F3namBMd53NgdICu5hp+b/PsR2uGiVo3b amRrOpzkO//0FC8uiskn7aSYNbeQypdCOK5UVzxb+wkmKpkdrUuibnQPQKvYYJLFS+Hxi5+jLOjr OwwGI3kKu05JnDlv7nAKet5ATEVyvcD3zonKMuho7Pcjf6jhxqhOSQCTP5WoiPg8NGrhBSlTYXv+ RODacxzptY+rCrOuY09B2sRDHIb2eFMGZroVA5iI4hFs1TgPiNaC014Vy40HEXgl5C8scPB9XYP7 vixq0HVs6U9Ty93KE5l5UpciHSgySfEf/Fl39R/2gMGq0KWAzmMf+ibVDlbJsvVTvDqJ6yGBbNGp n/klarSqmECMkPHOyvTSaWak76WS0gK94wcwLRgYWRwLFAmGZionQ8jFfz1/t0tMyqxPcEm80uax Dm7HyfjBsRHHPEeHyrAUT/s1ZQVvZW+9gG3TxtzLdFtJRh4rDAtZPKA= X-Report-Abuse-To: spam@semaster01.route25.eu X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:f10:305:0:1c00:d8ff:fe00:461 (failed) Received-SPF: pass client-ip=2a00:f10:305:0:1c00:d8ff:fe00:461; envelope-from=rladams@adamsinfoserv.com; helo=se08.route25.eu X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1643022803; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=wippZx9eZH1NGpRP++6vbZsC+9B8k/PK2JBlUNigZqc=; b=C+C11wRV48+jvmt0DHypFDVJFnnwiTT9QK+YgbkWdUgTet7L5sf2SwmeKYo8HV2j0Gk72W kiLcWiBv/c0VKBrTubNut24fkClzHEXkMdA7bbtb97SRUiXGpFQDY5aCzmvFnunaRzYVLi FRWGkm3Q7RdlDx23B3vGBwLxOqSjH1MhWcpDDLJdWRuNqC3ha4Er6bmvqZcL/5ozLl8yrc DKnfjiNuu243u+MyY1BQvlcpIdVx/0rxz2he/DtiTosxn7LVJDPt9v4OsP1kLngC08xFh1 rbTJVVac/IMn8zJKbJeokmkFjsrODa1HT18U15qhPfPoE0NfmZ6UTgMts+oZDw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1643022803; a=rsa-sha256; cv=none; b=ONkFcBG+phRp5wasmPwMolQ5myo0KSxhzKlxSIwjQEC6MvzXAOlHb3XVLJaQgLoZqGnv21 4Frqw6XrLtAhhVOS0t4emJK7qsGEs4bubs2RJnK/PM6kNnjq29FgvQwDjz9SxT6iUD/eq0 uYnUbCGDhXyIlg8Wcz4g/mPDZ3QzhCn0f76Z3Hqw4bP+RZYXcJhbfvYb75k1e9IwzXEYEv vMylyqkxLk/pprj3cwxQtS7V4UcGSL2zgAbTAk7D2sgihNcpTZLow2G5xH+Z4Z/MNgy5GM WRAFCsQTQJc3CbHKMgJWqo7tFfgsy2x6HuuLiMebijchJoTZQi/QTsB2RX8tPw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -2.93 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: A93043D9AB X-Spam-Score: -2.93 X-Migadu-Scanner: scn0.migadu.com X-TUID: ol0DnZOnqLR0 Why not just do an ASCII export to a temporary read only buffer for viewing? I always thought the point of Org was to have minimal markup so that the native file was plainly legible. On Sun, Jan 23, 2022 at 08:19:12AM +0100, Arthur Miller wrote: > Hi mailing list, > > is something like this of interest to add to org-mode? > > Attached is a prototype to a read-only view mode. It tries to hide as much of > markup as possible to make it more "readable". It uses built-in view-mode to > make the buffer read only and enable some common commands. I plan to add more > "dired like" movement though. > > I don't claim it is very well written or efficient; I appreciate input on that > regard. To note is that I use minor-modes as "toggles", to make the > functionality avialable as "solo pieces" as well as a code generation tool. > > I am just checking interest here. More info and a screencast are avialable at: > > https://github.com/amno1/org-view-mode > > ;;; org-view-mode.el --- Read-only viewer with less markup clutter in org mode files -*- lexical-binding: t; -*- > > ;; Copyright (C) 2021 Arthur Miller > > ;; Author: Arthur Miller > ;; Keywords: convenience, outlines, 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 . > > ;; Author: Arthur Miller > ;; Version: 0.0.1 > ;; Keywords: tools convenience > ;; Package-Requires: ((emacs "24.1")) > ;; URL: https://github.com/amno1/org-view-mode > > ;;; Commentary: > > ;; A minor mode to help reduce clutter in org-mode files by > ;; hiding/unhiding org-mode markup language > ;; > ;; To turn it on execute: > ;; > ;; `M-x org-view-mode'. > ;; > ;; To turn it off execute the same command. > > ;;; Issues > > ;;; Code: > (require 'org) > > (defgroup org-view nil > "Hide tags in org-headings." > :prefix "org-view-" > :group 'org) > > (defvar-local org-view-center-credentials nil > "Whether to align title and author in center or not. > > Centering is done pixel wise relative to window width.") > > (defcustom org-view-diminish-mode t > "Hide lighters for individual minor modes when org-view-mode is on." > :type 'boolean > :group 'org-view) > > (defvar org-view-stars-re "^[ \t]*\\*+" > "Regex used to recognize leading stars in org-headings.") > > (defvar org-view-credentials-re "[ \t]*#\\+\\(TITLE\\|AUTHOR\\):" > "Regex used to update author and title lines.") > > (defun org-view--update-tags (visibility) > "Update invisible property to VISIBILITY for tags in the current buffer." > (save-excursion > (goto-char (point-min)) > (with-silent-modifications > (while (re-search-forward org-view-stars-re nil t) > (goto-char (line-end-position)) > (when (re-search-backward org-tag-line-re (line-beginning-position) t) > (put-text-property > (match-beginning 1) (match-end 1) 'invisible visibility)) > (forward-line))))) > > (defun org-view--update-keywords (visibility) > "Set VISIBILITY for each line starting with a keyword from KEYWORDS list." > (org-with-wide-buffer > (save-excursion > (with-silent-modifications > (goto-char (point-min)) > (while (re-search-forward "^[ \t]*#\\+.*$" nil t) > (goto-char (match-beginning 0)) > (unless (looking-at-p org-view-credentials-re) > (put-text-property > (1- (match-beginning 0)) (match-end 0) 'invisible visibility)) > (goto-char (match-end 0))))))) > > (defun org-view--update-properties (visibility) > "Set invisible property to VISIBILITY for properties in the current buffer." > (org-with-wide-buffer > (save-excursion > (with-silent-modifications > (goto-char (point-min)) > (while (re-search-forward org-property-drawer-re nil t) > (put-text-property > (match-beginning 0) (match-end 0) 'invisible visibility)) > (goto-char (point-min)) > (while (re-search-forward "^[ \t]*#\\+PROPERTY:.*$" nil t) > (put-text-property > (1- (match-beginning 0)) (1+ (match-end 0)) 'invisible visibility)))))) > > (defun org-view--update-stars (visibility) > "Update invisible property to VISIBILITY for markers in the current buffer." > (org-with-wide-buffer > (save-excursion > (goto-char (point-min)) > (with-silent-modifications > (while (re-search-forward org-view-stars-re nil t) > (put-text-property > (match-beginning 0) (match-end 0) 'invisible visibility)))))) > > (defun org-view--update-credentials (visibility) > "Set invisible property to VISIBILITY for export settings." > (org-with-wide-buffer > (save-excursion > (with-silent-modifications > (goto-char (point-min)) > (while (re-search-forward org-view-credentials-re nil t) > (put-text-property > (match-beginning 0) (match-end 0) 'invisible visibility) > (when org-view-center-credentials > (org-view--center-in-window visibility))) > (goto-char (point-min)))))) > > (defun org-view--center-in-window (center) > "Center a line in a window pixel wise." > (save-excursion > (goto-char (line-beginning-position)) > (let ((end (line-end-position)) > (beg (line-beginning-position))) > (if center > (let* ((line (buffer-substring beg end)) > (length (/ (string-pixel-width line) 2))) > (put-text-property > beg (1+ beg) 'display `(space :align-to (- center (,length))))) > (remove-text-properties beg (1+ beg) '(display nil)))))) > > ;;;###autoload > (define-minor-mode org-view-hide-tags-mode > "Hide/show tags in org-headings." > :global nil :lighter " org-htm" > (unless (derived-mode-p 'org-mode) > (error "Not in org-mode")) > (org-view--update-tags org-view-hide-tags-mode)) > > ;;;###autoload > (define-minor-mode org-view-hide-stars-mode > "Hide/show leading stars in org-headings." > :global nil :lighter " org-hsm" > (unless (derived-mode-p 'org-mode) > (error "Not in org-mode")) > (org-view--update-stars org-view-hide-stars-mode)) > > ;;;###autoload > (define-minor-mode org-view-hide-keywords-mode > "Hide/show leading stars in org-headings." > :global nil :lighter " org-hkm" > (unless (derived-mode-p 'org-mode) > (error "Not in org-mode")) > (org-view--update-keywords org-view-hide-stars-mode)) > > ;;;###autoload > (define-minor-mode org-view-hide-properties-mode > "Hide/show properties and property drawers." > :global nil :lighter " org-hpm" > (unless (derived-mode-p 'org-mode) > (error "Not in org-mode")) > (org-view--update-properties org-view-hide-properties-mode)) > > ;;;###autoload > (define-minor-mode org-view-pretty-credentials-mode > "Prettify credentials in org-buffers." > :global nil :lighter " org-pcm" > (unless (derived-mode-p 'org-mode) > (error "Not in org-mode")) > (org-view--update-credentials org-view-pretty-credentials-mode)) > > (defun org-view-quit () > (interactive) > (org-view-mode -1) > (message "org-view mode disabled in current buffer")) > > (defvar-keymap org-view-mode-map > :doc "Keymap for ‘ORG-view-mode’" > "c" #'org-view-quit > "C" #'org-view-quit > "e" #'org-view-quit > "E" #'org-view-quit > "q" #'org-view-quit > "Q" #'org-view-quit) > > ;;;###autoload > (define-minor-mode org-view-mode > "Hide/show babel source code blocks on demand." > :global nil :lighter " org-view" :keymap org-view-mode-map > (unless (derived-mode-p 'org-mode) > (error "Not in org-mode")) > (cond (org-view-mode > (org-view-hide-tags-mode org-view-mode) > (org-view-hide-stars-mode org-view-mode) > (org-view-hide-keywords-mode org-view-mode) > (org-view-hide-properties-mode org-view-mode) > (org-view-pretty-credentials-mode org-view-mode) > (when org-view-diminish-mode > (dolist (mode '(org-view-hide-tags-mode > org-view-hide-stars-mode > org-view-hide-keywords-mode > org-view-hide-properties-mode > org-view-pretty-credentials-mode)) > (let ((mode-str (cdr (assq mode minor-mode-alist)))) > (setcar mode-str "")))) > (view-mode +1)) > (t (view-mode -1) > (org-view-hide-tags-mode -1) > (org-view-hide-stars-mode -1) > (org-view-hide-keywords-mode -1) > (org-view-hide-properties-mode -1) > (org-view-pretty-credentials-mode -1)))) > > (provide 'org-view-mode) > > ;;; org-view-mode.el ends here ------------------------------------------------------------------ Russell Adams RLAdams@AdamsInfoServ.com PGP Key ID: 0x1160DCB3 http://www.adamsinfoserv.com/ Fingerprint: 1723 D8CA 4280 1EC9 557F 66E8 1154 E018 1160 DCB3