Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide cloze expression curly brackets #135

Open
ronnac opened this issue Nov 21, 2024 · 0 comments
Open

Hide cloze expression curly brackets #135

ronnac opened this issue Nov 21, 2024 · 0 comments

Comments

@ronnac
Copy link

ronnac commented Nov 21, 2024

I wrote a toggle-hide-cloze-brackets function for those of us who use their actual notes as flashcards and want to keep it readable.

(setq cloze-expression-keyword
      ;; group 0 is the cloze expression in curly brackets
      ;; group 1 is the actual contents of the cloze, without the hints, brackets and @1 etc
      '((
      "^.*\\({{\\(.*\\)}@.*}\\).*$"
         ;; The previous regex was the anchor, this is the real hightlight
         "{{\\|}}\\|}\\({[^}]+}\\)?@[0-9]*}"
         (goto-char (match-beginning 0))
         nil
         (0 (put-text-property (match-beginning 0) (match-end 0) 'display "")))))

(setq hide-cloze-brackets 1)

(defun toggle-hide-cloze-brackets()
  (interactive)
  (if hide-cloze-brackets
      (progn
        (font-lock-remove-keywords 'org-mode cloze-expression-keyword)
        (setq hide-cloze-brackets nil))
    (progn
      (font-lock-add-keywords 'org-mode cloze-expression-keyword)
      (setq hide-cloze-brackets 1))
    )
  (org-mode-restart))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant