Git Product home page Git Product logo

org-view-mode's Introduction

org-view-mode

https://melpa.org/packages/org-view-mode-badge.svg https://img.shields.io/badge/License-GPLv3-blue.svg

This is my attempt to reduce clutter when viewing org-mode files. I think it looks noisy to look at all the markup, especially in README files when they are displayed in Dired buffers with my dired-auto-readme mode. When viewing org-files, I am usually mostly interested in the content, not so in markup. Org-view-mode is an attempt to create a read-only “viewer” mode. Thus per definition, this minor mode is for consuming org content, not so much for creating it. It could be actually renamed org-readme-mode, since I have created it mostly to read README files in git repos without unnecessary noise :-). Also, don’t expect this to work well with org-capture, agendas, etc.

Screencast

./images/screencast.gif

Installation

Melpa

The package is now available from Melpa repository, so if you have Melpa included in your package archives, you can install org-view-mode either via built-in Emacs package manager with

M-x package-install RET org-view-mode RET

Or if you use use-package you can just do:

(use-package org-view-mode
  :ensure t)

Package.el

You can download org-view-mode.el somewhere and use package.el to install file: M-x package-install-file RET and follow the prompt.

Straight

You may use straight.el to install this package, or some combination of straight & use-package

;; straight.el
(straight-use-package
 '(org-view-mode :type git :host github :repo "amno1/org-view-mode"))

;; use-package & straight
(use-package org-view-mode
             :straight (org-view-mode :type git :host github :repo "amno1/org-view-mode"))

Manual

Either clone this repo or just download ‘org-view-mode.el’.

Put org-view-mode.el somewhere in Emacs load-path. From there you can just require the file somewhere in your init file or add autoload for org-view-init mode to your init file.

Requirements

Org-view does not use any external packages. Minimal Emacs version supported is probably 25.1.

Usage

Org-view mode

M-x org-view-mode to turn it on/off.

Shortcuts

Org-view-mode uses two mode maps: org-view-mode-map and org-view-edit-mode-map.

The former is active when read-only mode is on, while the latter is active when quick editing file. There really are not so many actions defines, only two: enter-edi mode and exit org-view-mode. Of course org-mode map(s) are active all the time. Maybe at some point in the future I might go through the mode and choose which ones to enable or disable, but for the current, be aware that all org-mode shortcuts are active and that some might not work due to read-only status of the buffer while in org-view-mode.

Fill-column

Some elements are centered in window in respect to fill-column value. Those are currently paragraphs marked with begin/end-centered, title, author, and email address. If fill-column is for some reason nil or invalid (less than 1), org-view will use the default fill-column of 80 columns. Controlled with:

org-view-default-fill-column

variable. Its value can be customized in customize options.

Hiding markup

Org-view-mode will by default hide any line starting with ‘#+’ to the end of that line. Also the new line character before that line is hidden, so that there are no visible empty lines where hidden text is. You can set:

org-view-hide-keywords

to nil to disable it.

In addition to regular markup, even some agenda keywords are hidden: DEFAULT: and SCHEDULED:. Hiding those can be disabled by setting:

org-view-hide-agenda-keywords

to nil. Note that both variables have to be ‘t in order to hide agenda keywords.

Pretty Credentials

To disable centering of title, author and email, set org-view-prettify-credentials to nil value.

Centering is done with respect to fill-column value.

Only the author and email keywords are prettified as of currently along with the title keyword too. Co-authors are not yet prettified and are hidden by default, as org-view does with other markup. Patch is welcome if someone would like to implement that.

Hiding ellipses

By default outline-mode display ellipses instead of hidden text. Org-view-mode can hide those too. Unfortunately it does not see possible to hide ellipses only at some places, since it depends on a value in display-table. At least I don’t see how to change it, I have tried to bind selective-display-ellipses and org-ellipses in various ways in order to hide them, but it does not seem to do anything. Changing the value in buffer-display-table does the trick, but it is all or nothing approach. Since it also removes ellipses from headlines, there is no indication if the content is toggled or not. For that reason the default value is off. The variable in control is: //org-view-hide-ellipses/. Use it at your own risk..

Pretty Headings

By default org-view-mode hides leading stars in outline headings. You can disable it by setting org-view-hide-stars to nil.

Hiding tags and properties can be disabled by setting org-view-hide-tags and org-view-hide-properties to nil.

Pretty Quotes and Verses

Org-view will by default display text marked as quote and verse with their own face and aligned to the left. To disable paragraph prettification set ort-view-prettify-paragraphs to nil.

The alignment is done in respect to the longest line in the paragraph. Variables to control the alignment with are org-view-quote-align and org-view-verse-align.

The control values you can assign to each are: ‘left, ‘right and ‘middle.

Paragraphs marked with begin/end-center are always aligned in the middle. The effect of each alignment is shown in the screenshot below:

./images/paragraphs-alignement.png

In quote and verse paragraphs it is also possible to prettify the author if it is specified. The author should be prefixed with (three dashes) and stretches to the end of the buffer line. By default, dashes are replaced with Unicode drawing characters: ───. This option is controlled with org-view-author-prefix.

Faces used to display quotes, verses and credentials are:

org-view-quote-face, org-view-verse-face and org-view-author-face

which can all be customized via customize options.

For other options avialable please see the org-view group in customize:

M-x customize-group RET org-view

Org View Font

Org view mode comes with an optional org-view-font feature. This gives you the ability to use a variable pitch/alternate font for reading org documents.

You may utilize it by customizing the following variables:

  • org-view-font-enable to enable/disable the org-view-font feature
  • org-view-font-remaps (alist) to add/remove explicit face settings for org-mode
  • org-view-font-no-remap (list) to protect specific faces from being remapped

Use M-x customize-group org-view-font to view these customization options in one view.

You may also customize the view font with elisp:

(require 'org-view-mode)
(setq org-view-font-enable)
(add-to-list 'org-view-font-remaps '(default . (:family "Noto Sans")))

Add 3rd party mode

For example, if you would like to enable an additional mode, say org-bullets, and only in org-view-mode, you can do something like this:

(add-hook 'org-view-mode-hook
          (lambda ()
            (if org-view-mode
                (org-bullets-mode +1)
              (org-bullets-mode -1))) nil t)

Org-bullets, replace stars in headings with unicode characters, so in order to see the bullets in org-mode, you have to tell org-view-mode not to hide stars, by customizing the org-view-hide-stars to nil.

Of course, you will have to apropriately load org-bullets somewhere in your init file as well.

Issues

There might be lots of issues I am not aware of, since I haven’t extensively used this with many org files.

I would like to hear input, ideas, suggestions and problems found. I don’t promise to implement everything or any at all, but if something can be implemented relatively easily and is useful, I would like to hear the idea. Let me know.

Special thanks

I am not a very good user of org-mode myself, so I don’t have any org-mode files. with complex markup of my own, so I have used some from others for both tests and the screencast above. I would like to thank the authors for putting up their code and README files and for letting us use them freely, in order of the appearance in the screencast above, to Omar Antolín Camarena for Orderless, Takaaki Ishikawa for moom, Protesilaos Stavrou for mct and Okamsn for loopy. Thank you.

License

GPL v3. For details, see the attached license file.

org-view-mode's People

Contributors

amno1 avatar skx avatar trev-dev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

emacsmirror

org-view-mode's Issues

Feature Request: hide ellipsis

when a drawer is collapsed the org-ellipsis string is shown instead.

image

image

enabling org-view-mode when the drawer is collapsed will still show the ellipsis

image

this does not happen if org-view-mode is enabled when the drawer is expanded

image

Adding a "org-view-reading-font-mode"

I'd like to contribute an optional "reading font mode" to compliment this minor mode and wanted to brainstorm a bit about what this could look like.

I was thinking of the following:

  1. A toggle variable so that this feature could be easily customized off: org-view-reading-font-enable
  2. A customizable variable for which font to use: org-view-reading-font-family
  3. A customizable font-size per face fields list with default settings. This way one could customize which headings get what size and what the paragraph sizes would be: org-view-reading-font-sizes
  4. A couple of pre-installed, open source fonts that are intended for readability. One sans-serif, the other would be serif. Not sure which fonts these would be yet.

Thoughts?

Accessible screencast

Many developers put a screencast / screenshot to help others understand what to expect.
If that is what is intended in the screencast file, I urge you to consider accessibility by improving the contrast.
The best way to do it is to use a white background with darker text. It will help in improved readability of the screencast.

Installing problems

If I try:
package-install-file org-view-mode.el

I receive:
package-buffer-info: Package lacks a file header

If I try:
(require 'org-view-mode)

Then:
load-with-code-conversion: Symbol’s value as variable is void: <!DOCTYPE

org-font-lock-ensure is deprecated

For reference: org-roam/org-roam#2235

On my current install, org-font-lock-ensure doesn't even exist, so this package will not work. Will we support backward-compatibility for emacs < 26? The necessary corner case will need to be taken into consideration if the answer is "yes". Otherwise, we should replace org-font-lock-ensure with font-lock-ensure

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.