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

feat: "auto" level property & no-first-heading #195 #254 #268

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
25 changes: 22 additions & 3 deletions org-transclusion-font-lock.el
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
;;; org-transclusion-font-lock.el --- font-lock for Org-transclusion -*- lexical-binding: t; -*-

;; Copyright (C) 2021-2024 Free Software Foundation, Inc.
;; Copyright (C) 2021-2025 Free Software Foundation, Inc.

;; 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
Expand All @@ -17,7 +17,7 @@

;; Author: Noboru Ota <me@nobiot.com>
;; Created: 22 August 2021
;; Last modified: 21 January 2024
;; Last modified: 02 January 2025

;;; Commentary:
;; This file is part of Org-transclusion
Expand All @@ -26,7 +26,26 @@
;;; Code:

(require 'org)
(add-hook 'org-font-lock-set-keywords-hook #'org-transclusion-font-lock-set)
(require 'org-transclusion)

;;;###autoload
(define-minor-mode org-transclusion-font-lock-mode ()
:lighter nil
:global t
:group 'org-transclusion
(if org-transclusion-font-lock-mode
(org-transclusion-extension-functions-add-or-remove
org-transclusion-font-lock-extension-functions)
(org-transclusion-extension-functions-add-or-remove
org-transclusion-font-lock-extension-functions :remove)))

(defvar org-transclusion-font-lock-extension-functions
(list (cons 'org-font-lock-set-keywords-hook #'org-transclusion-font-lock-set))
"Alist of functions to activate `org-transclusion-font-lock'.
CAR of each cons cell is a symbol name of an abnormal hook
\(*-functions\). CDR is either a symbol or list of symbols, which
are names of functions to be called in the corresponding abnormal
hook.")

(defface org-transclusion-keyword
'((((class color) (min-colors 88) (background light))
Expand Down
22 changes: 20 additions & 2 deletions org-transclusion-html.el
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
;;; org-transclusion-html.el --- Converting HTML content to Org -*- lexical-binding: t; -*-

;; Copyright (C) 2024 Free Software Foundation, Inc.
;; Copyright (C) 2024-2025 Free Software Foundation, Inc.

;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU Affero General Public License
Expand Down Expand Up @@ -31,6 +31,7 @@

;;;; Requirements

(require 'org-transclusion)
(require 'org)
(require 'org-element)
(require 'cl-lib)
Expand All @@ -39,7 +40,24 @@

;;;; Hook into org-transclusion

(add-hook 'org-transclusion-add-functions #'org-transclusion-html-add-file)
;;;###autoload
(define-minor-mode org-transclusion-html-mode ()
:lighter nil
:global t
:group 'org-transclusion
(if org-transclusion-html-mode
(org-transclusion-extension-functions-add-or-remove
org-transclusion-html-extension-functions)
(org-transclusion-extension-functions-add-or-remove
org-transclusion-html-extension-functions :remove)))

(defvar org-transclusion-html-extension-functions
(list (cons 'org-transclusion-add-functions #'org-transclusion-html-add-file))
"Alist of functions to activate `org-transclusion-html'.
CAR of each cons cell is a symbol name of an abnormal hook
\(*-functions\). CDR is either a symbol or list of symbols, which
are names of functions to be called in the corresponding abnormal
hook.")

;;;; Functions

Expand Down
26 changes: 22 additions & 4 deletions org-transclusion-indent-mode.el
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
;;; org-transclusion-indent-mode.el --- support org-indent-mode -*- lexical-binding: t; -*-

;; Copyright (C) 2021-2024 Free Software Foundation, Inc.
;; Copyright (C) 2021-2025 Free Software Foundation, Inc.

;; 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
Expand All @@ -17,20 +17,38 @@

;; Author: Noboru Ota <me@nobiot.com>
;; Created: 22 August 2021
;; Last modified: 21 January 2024
;; Last modified: 02 January 2025

;;; Commentary:
;; This file is part of Org-transclusion
;; URL: https://github.com/nobiot/org-transclusion

;;; Code:

(require 'org-transclusion)
(require 'org-indent)
(declare-function org-transclusion-within-transclusion-p
"org-transclusion")

(add-hook 'org-transclusion-after-add-functions
#'org-translusion-indent-add-properties)
;;;###autoload
(define-minor-mode org-transclusion-indent-mode ()
:lighter nil
:global t
:group 'org-transclusion
(if org-transclusion-indent-mode
(org-transclusion-extension-functions-add-or-remove
org-transclusion-indent-extension-functions)
(org-transclusion-extension-functions-add-or-remove
org-transclusion-indent-extension-functions :remove)))

(defvar org-transclusion-indent-extension-functions
(list (cons 'org-transclusion-after-add-functions
#'org-translusion-indent-add-properties))
"Alist of functions to activate `org-transclusion-indent-mode'.
CAR of each cons cell is a symbol name of an abnormal hook
\(*-functions\). CDR is either a symbol or list of symbols, which
are names of functions to be called in the corresponding abnormal
hook.")

(defun org-translusion-indent-add-properties (beg end)
"BEG END."
Expand Down
72 changes: 42 additions & 30 deletions org-transclusion-src-lines.el
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
;;; org-transclusion-src-lines.el --- Extension -*- lexical-binding: t; -*-

;; Copyright (C) 2021-2024 Free Software Foundation, Inc.
;; Copyright (C) 2021-2025 Free Software Foundation, Inc.

;; 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
Expand All @@ -17,14 +17,15 @@

;; Author: Noboru Ota <me@nobiot.com>
;; Created: 24 May 2021
;; Last modified: 27 December 2024
;; Last modified: 02 January 2025

;;; Commentary:
;; This is an extension to `org-transclusion'. When active, it adds features
;; for non-Org files such as program source and text files

;;; Code:

(require 'org-transclusion)
(require 'org-element)
(declare-function text-clone-make-overlay "text-clone")
(declare-function org-transclusion-live-sync-buffers-others-default
Expand All @@ -34,34 +35,45 @@

;;;; Setting up the extension

;; Add a new transclusion type
(add-hook 'org-transclusion-add-functions
#'org-transclusion-add-src-lines)
;; Keyword values
(add-hook 'org-transclusion-keyword-value-functions
#'org-transclusion-keyword-value-lines)
(add-hook 'org-transclusion-keyword-value-functions
#'org-transclusion-keyword-value-src)
(add-hook 'org-transclusion-keyword-value-functions
#'org-transclusion-keyword-value-rest)
(add-hook 'org-transclusion-keyword-value-functions
#'org-transclusion-keyword-value-end)
(add-hook 'org-transclusion-keyword-value-functions
#'org-transclusion-keyword-value-thing-at-point)
;; plist back to string
(add-hook 'org-transclusion-keyword-plist-to-string-functions
#'org-transclusion-keyword-plist-to-string-src-lines)

;; Transclusion content formatting
(add-hook 'org-transclusion-content-format-functions
#'org-transclusion-content-format-src-lines)

;; Open source buffer
(add-hook 'org-transclusion-open-source-marker-functions
#'org-transclusion-open-source-marker-src-lines)
;; Live-sync
(add-hook 'org-transclusion-live-sync-buffers-functions
#'org-transclusion-live-sync-buffers-src-lines)
;;;###autoload
(define-minor-mode org-transclusion-src-lines-mode ()
:lighter nil
:global t
:group 'org-transclusion
(if org-transclusion-src-lines-mode
(org-transclusion-extension-functions-add-or-remove
org-transclusion-src-lines-extension-functions)
(org-transclusion-extension-functions-add-or-remove
org-transclusion-src-lines-extension-functions :remove)))

(defvar org-transclusion-src-lines-extension-functions
(list
;; Add a new transclusion type
(cons 'org-transclusion-add-functions #'org-transclusion-add-src-lines)
;; Keyword values
(cons 'org-transclusion-keyword-value-functions
'(org-transclusion-keyword-value-lines
org-transclusion-keyword-value-src
org-transclusion-keyword-value-rest
org-transclusion-keyword-value-end
org-transclusion-keyword-value-thing-at-point))
;; plist back to string
(cons 'org-transclusion-keyword-plist-to-string-functions
#'org-transclusion-keyword-plist-to-string-src-lines)
;; Transclusion content formatting
(cons 'org-transclusion-content-format-functions
#'org-transclusion-content-format-src-lines)
;; Open source buffer
(cons 'org-transclusion-open-source-marker-functions
#'org-transclusion-open-source-marker-src-lines)
;; Live-sync
(cons 'org-transclusion-live-sync-buffers-functions
#'org-transclusion-live-sync-buffers-src-lines))
"Alist of functions to activate `org-transclusion-src-lines'.
CAR of each cons cell is a symbol name of an abnormal hook
\(*-functions\). CDR is either a symbol or list of symbols, which
are names of functions to be called in the corresponding abnormal
hook.")

;;; Functions

Expand Down
Loading
Loading