Is it possible that when I press CMD-O on a MD document it opens in edit mode BUT when I click on it (in standard preview view) it shows the MD preview?
I have option Markdown Display set to Preview Documents. CMD-O also opens as preview.
Is it possible that when I press CMD-O on a MD document it opens in edit mode BUT when I click on it (in standard preview view) it shows the MD preview?
I have option Markdown Display set to Preview Documents. CMD-O also opens as preview.
In Karabiner-Elements, it should be possible to create a custom keyboard rule which does the following:
I donât use KE myself, so canât provide more information on how to accomplish that.
A similar approach might be possible with other apps, eg Keyboard Maestro or Better Touch Tool.
I will investigate. Thanks.
@saltlane Just to give you an idea of what this could look like in BetterTouchTool.
â + O is executed if no other key is pressed within 0.2 seconds.
â + O + O is executed if the pause after the first O is shorter than 0.2 seconds.
This is an example, you can do it in different ways
Yes, that too.
FYI - I tried using Keyboard Maestro (KM) but unfortunately setting for double tap CMD-O it blocks the single tap CMD-O.
Temporarily I have set KM so ALT-O executes CMD-O followed by CTRL-CMD-X. It has the added bonus that on other file types you can switch between best alternative and text alternative depending on if you type CMD-O or ALT-O.
I will play more. It may be better just to get used to typing CTRL-CMD-X
I donât know KM that well. But I think there are trigger options âis tapped only onceâ etc. So that should actually work, no?
Ah, but wait, looking at your macro, Iâm not sure what you want to do. A cycle action? Or should the two shortcuts be executed one after the other?
Thanks. I tried this, but it does funny things if opening other document types. I couldnât workout how to limit it for MD docs only.
For some documents types Ctrl-CMD-X sets them to text alternative view.
⌠and also HTML and WebArchive.
In the end UI scripting is probably the simplest approach. No keyboard app required.
try
tell application id "DNtp"
activate
set theRecord to item 1 of selected records
if type of theRecord is markdown then
open tab for record theRecord -- optionally, `in think window 1`
else
return
end if
delay 0.2
end tell
tell application "System Events"
tell process "DEVONthink 3"
click menu item "Source" of menu 1 of menu item "Document Display" of menu 1 of menu bar item "View" of menu bar 1
end tell
end tell
end try
Assign a custom keyboard shortcut to this script, and itâs good to go.
UI scripting is known to be fragile and unreliable. YMMV
Indeed, though itâs perhaps not more fragile than keyboard macros; I assume the KM action for clicking menu item in @TonyLim 's screenshot is essentially a wrapper for System Events.
So, my previous request again: Can we get direct scripting control for the document views?
Thatâs not a decision I can make. And scripting the interface of an application is often the wrong idea as can lead to Rube Goldergian machinations. Scripting isnât for creating an automoton; it is for creating actions and reactions in a process. Itâs more akin to chemistry than robotics.
However, the request is (still) noted.
Thatâs a good point, although I feel insistence on âcleannessâ can be a red herring for developers. Fewer customization opportunities (scripting and settings), IMHO, do not reduce the variety of needs of the user.
We already have open window for
and open tab for
, in DT and other applications as well. I take that as an indication that there is indeed a need â an appreciated one â for controlling the appearance of user data through automation.
Anyway, thanks for considering. Have a good day.
Did you set up both macros?
AND
Iâm afraid thatâs not possible. KM would have to recognize where the cursor is currently located or what is currently being selected. It also doesnât work with the names of text fields, because the fields have the same name.
Edit: If your MD docs have something unique in their name, for example âMDâ , then you can create a condition.
Something like this. But I donât really understand KM.
Yes I did set up both. Thanks.
The problem is that KM canât see into the future so doesnât know you are going to double tap and always executes the single CMD-O routine. The double tap never gets executed (in my tests anyway).
Thatâs a good point, although I feel insistence on âcleannessâ can be a red herring for developers.
Fewer customization opportunities (scripting and settings), IMHO, do not reduce the variety of needs of the user.
I donât believe itâs about âcleannessâ.
The problem is when the user believes they need something they donât. For example, itâs not uncommon for people to look for commands to click buttons. Or they think things like, âI need a script to double-click on this group then select all the text documents in it then press the Merge command in the Tools menu, because thatâs what I do every week.â Those are not actions a script should, or needs to, take. Again, itâs not about building a robot to push the buttons for you. Extending UI scripting reinforces the misunderstanding of what automation is.
PS: This one-liner (not necessarily recommended but quick for me to protoype and iterate on), essentially fulfills the example action mentioned aboveâŚ
tell application id "DNtp" to set bounds of (open tab for record (merge records (children of (get record at "/Text/Files/Plain text/" in database "File Types") whose (type is txt))))'s think window to {350, 0, 1100, 800}
No group double-clicking group. No selecting documents. No button clicking. And it even opens the resulting document in a new document window, without having to ââŚfind and select the new document and double-click it to open it in a new windowââŚ
Oh, and it also resizes the window to roughly the middle of my screen
And hereâs the less insane and more readable/instructional/error-trapped versionâŚ
property activeDB : "File Types"
property removeOriginals : true
tell application id "DNtp"
if not (exists database activeDB) then return -- Optionally, the database could be opened.
set sourceGroup to (get record at "/Text/Files/Plain text/" in database activeDB)
set recordsToMerge to (children of sourceGroup whose (type is txt))
if recordsToMerge is not {} then
set mergedDoc to merge records recordsToMerge
set theTab to open tab for record mergedDoc
set bounds of think window of theTab to {350, 0, 1100, 800}
if removeOriginals then move record recordsToMerge to trash group of database activeDB
end if
end tell
Weird, it works for me.
Thatâs not necessary. KM simply waits. If nothing more comes after the O, something is executed, if another O comes, something else.