A group merge view would be handy

You can preview documents with two views, widescreen being my favorite, but there’s no preview of groups.

It would be handy to be able to preview a group as a merge of its constituent documents.

For instance, I like to storyboard by adding tags to notes. The tag becomes an inventory of what I want to use in a section of a story I’d like to write.

Imagine clicking on a tag or group and instead of seeing “no selection,” you saw a merge of the files. As I tagged and untagged, and dragged to adjust order, going back to the group or tag would show a rearranged merge.

That would be cool, wouldn’t it?

3 Likes

Thank you for the suggestion! However, there are currently no such plans as DEVONthink’s databases can contain a lot of document types and as DEVONthink’s primary usage scenario is info/document management, not writing. But maybe some day.

Would you use a script?

Pete, that was my next thought.

@cgrunenberg - My primary use for Devonthink is for document management, so I’m in your demographic. I use it to manage correspondence and financial records both for myself and for the non-profit corporation I serve as treasurer.

I do enjoy my dark and stormy nights, too, and DT is such a friendly companion for any kind of organization tasks. I think I’ll experiment with a script or two.

1 Like

It would be handy to be able to preview a group as a merge of its constituent documents.

Can you clarify what you mean by this?

Transclusion, I think.

Maybe Script: Refreshable/Portable merged view of files in mixed formats + direct[almost] editing/addition of source files + dynamically linked to the contents of groups/tags?

Not in Python, though :wink:

Ahh… perhaps that is so.

That script looks interesting! I’ll have to study that.

Imagine you are working on a project (or writing a chapter in a book) and want to tag notes as components of what you’re working on.

You can click on individual notes and see them individually, but consider clicking on a group or tag and seeing a view identical to “merge documents.”

The difference would be it would be a live aggregation. Every time you changed the component documents in the group or tag, the merged view would update.

A script might be fun, or I can just use the merge documents function.

2 Likes

Being able to see, overview several notes (eg „atomic notes“) at the same time, is also something I would find very useful. Scrivener Has the widely praised corkboard and in Agenda one has several notes in view at the same time. I like your idea of a virtual or only displayed merge view of (md) notes.

2 Likes

This script creates a transclusion for the current group’s Markdown records.

-- Create transclusion for current group's Markdown records

tell application id "DNtp"
	try
		if not (exists think window 1) then error "Please open a window"
		set theGroup to current group
		set theChildren_ReferenceURLs to reference URL of children of theGroup whose type = markdown and comment is not "Transcluded group contents"
		if theChildren_ReferenceURLs = {} then error "This group doesn't contain Markdown records"
		set theTransclusionRecord_Source to "{{" & my tid(theChildren_ReferenceURLs, "}}" & linefeed & "{{") & "}}"
		set theTransclusionRecord to create record with {name:"_Transclusion - " & (name of theGroup), type:markdown, source:theTransclusionRecord_Source, comment:"Transcluded group contents"} in theGroup
		open window for record theTransclusionRecord
		activate
		
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
		return
	end try
end tell

on tid(theInput, theDelimiter)
	set d to AppleScript's text item delimiters
	set AppleScript's text item delimiters to theDelimiter
	if class of theInput = text then
		set theOutput to text items of theInput
	else if class of theInput = list then
		set theOutput to theInput as text
	end if
	set AppleScript's text item delimiters to d
	return theOutput
end tid
5 Likes

Thanks for posting the script! I didn’t try this so far but I just wondered whether an advanced triggered script (see Script option in Info inspector) of groups could automatically create/update the transclusion or even automatically select it.

2 Likes

This script creates/updates a Transclusion record for the group’s Markdown records and selects or opens it in a new window.

From help:

Attaching a triggered script

  • Select the item you want to attach a script to.
  • Select Tools > Get Info or Tools > Inspectors > Generic.
  • Click the down arrow next to Script and choose Select. Note the script can be located anywhere, but it must remain in that location for the script to trigger. For convenience, you can create a folder for them in ~/Library/Application Scripts/com.devon-technologies.think3/Menus.
-- Triggered script - Create transclusion for current group's Markdown records

-- Setup: Click "script" in a group's info inspector. Select path

property selectTransclusionRecord : true -- if false Transclusion record opens in a new window

on triggered(theGroup)
	tell application id "DNtp"
		try
			set theResults to search "kind:markdown comment:\"Transcluded group contents\"" in theGroup
			if theResults ≠ {} then
				set theTransclusionRecord to item 1 of theResults
			else
				set theTransclusionRecord to create record with {name:"_Transclusion - " & (name of theGroup), type:markdown, source:"", comment:"Transcluded group contents"} in theGroup
			end if
			
			set theChildren_ReferenceURLs to reference URL of children of theGroup whose type = markdown and comment is not "Transcluded group contents"
			if theChildren_ReferenceURLs = {} then error "This group doesn't contain Markdown records"
			set theTransclusionRecord_Source to "{{" & my tid(theChildren_ReferenceURLs, "}}" & linefeed & "{{") & "}}"
			set plain text of theTransclusionRecord to theTransclusionRecord_Source
			
			if selectTransclusionRecord then
				set selection of think window 1 to {theTransclusionRecord}
			else
				open window for record theTransclusionRecord
				activate
			end if
			
		on error error_message number error_number
			if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
			return
		end try
	end tell
end triggered

on tid(theInput, theDelimiter)
	set d to AppleScript's text item delimiters
	set AppleScript's text item delimiters to theDelimiter
	if class of theInput = text then
		set theOutput to text items of theInput
	else if class of theInput = list then
		set theOutput to theInput as text
	end if
	set AppleScript's text item delimiters to d
	return theOutput
end tid

@cgrunenberg By the way, I know this has been asked several times and will probably not be implemented but it would be very very useful if we could set some window properties. Especially setting the state of the preview, the sidebar and the inspector would be very handy (at least whether they are shown or not). Bonus points if we could open the inspector to specific tabs :wink: Thank you very much for all the new AppleScript stuff, it’s amazing that almost everything users asked for is implemented after some months.

2 Likes

Nice :+1:

1 Like

Awesome!

I was going to try this last night but got stuck in a rabbit hole. Long story - it looked like I had permissions issues on files. I didn’t, but I still blew an evening.

This script is really cool and works perfectly. I can set the script on a tag, then as I tag new files, they appear in the next view of the transclusion.

To access the transclusion, click the tag or group. To access the members of the tag or group, expand first and choose the member you want to mess with.

Pete, if you ever find yourself in Central Texas, the Bar-B-Que is on me. The first time I ran this script it was like a great disturbance in the force, as if millions of voices cried “Hooray!” and suddenly silenced as they turned to their keyboards.

It’s that nice.

5 Likes

I’m pretty sure Pete can script a BBQ wherever he wants :smiley:

1 Like

Nice use of text item delimiters :slight_smile:

1 Like

Interesting use of the comment “Transcluded group contents” to exclude the transclusion from transcluding itself.

Although, for producing “All work and no play” in a snowed-in haunted resort, I suppose you could delete that clause and save yourself a lot of typing.

Probably one of the all-time best user-contributed scripts. A+++

3 Likes