emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Matt Price <moptop99@gmail.com>
To: Org Mode <emacs-orgmode@gnu.org>
Subject: modifying/deleting ovelrays; also, un-sparsifying tree?
Date: Fri, 29 Jul 2016 10:31:46 -0400	[thread overview]
Message-ID: <CAN_Dec_APZf0vO7xpo7Qpzuq6mM_5Sn+QJ10pRY6MD8MFqSFvw@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2237 bytes --]

In my gradesheets I use overlays to display the grade property in headlines
-- that way I can see at a glance approximately how my students are doing:

;; still imperfect, but good enough for me.
(defun org-grading-overlay-headings ()
  "Show grades at end of headlines that have a 'GRADE' property."
  (interactive)
  (require 'ov)

  (org-map-entries
   (lambda ()
     (when (org-entry-get (point) "GRADE")
       (ov-clear (- (line-end-position) 1)
                 (+ 0 (line-end-position)))
       (setq ov (make-overlay (- (line-end-position) 1)
                              (+ 0 (line-end-position))))
       (setq character (buffer-substring (- (line-end-position) 1)
(line-end-position)))
       (overlay-put
        ov 'display
        (format  "%s  GRADE: %s CHITS: %s" character (org-entry-get (point)
"GRADE") (org-entry-get (point) "CHITS")))
       (overlay-put ov 'name "grading")
       (message "%s" (overlay-get ov "name")))))
  )

This mostly works, except that I've noticed that, when I regenerate the
overlays after changes, certain folded trees end up with a duplicate
overlay, for reasons that I don't quite understand (maybe because the
ellipses at the end of the fold interfere with my counting somehow)?
I ould like to be able to find the named overlays and remove them all at
once, something like this:

(defun matt-clear-overlay ()
  (interactive)
  (let ((all-overlays (overlays-in (point-min) (point-max))))
    (dolist (x all-overlays)
      (if (string= (overlay-get x "name") "grading")
          (delete-overlay x)
          )))) ;; sorry for hanging brackets, I know it's bad form

this doesn't seem to do anything, so maybe I'm not testing right, or I'm
misnderstanding overlays. In any case ,I would love to be able to locate
the overlays properly, and modify or delete-and-recreate them
appropriately. Can you guys help out? Just clearing all overlays is not a
good option, as org seems to make heavy use of them to hide e.g. property
drawers.

An unrelated simple question: if I make a sparse tree (e.g. by searching
for all subtrees with a "GRADE" property of "0" or "FAIL",), can i
un-sparsify hte buffer afterwards? I didn't immediately find that option in
the manual.

thanks everyone!
matt

[-- Attachment #2: Type: text/html, Size: 2779 bytes --]

             reply	other threads:[~2016-07-29 14:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-29 14:31 Matt Price [this message]
2016-07-29 14:46 ` modifying/deleting ovelrays; also, un-sparsifying tree? Nicolas Goaziou
2016-07-29 15:31   ` Matt Price
2016-07-29 16:21     ` Matt Price
2016-07-29 22:31       ` Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAN_Dec_APZf0vO7xpo7Qpzuq6mM_5Sn+QJ10pRY6MD8MFqSFvw@mail.gmail.com \
    --to=moptop99@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).