Press ⌘⇧D while in Preview.app and it will prompt you to see if you want to delete the current document. It will show you the filename to help confirm that you are getting rid of the proper file.
If you confirm, it will close the document and move it to the trash. It works properly with tabs and multiple documents in the same window.
The second macro (not shown in the image) is mostly the same thing, except for two important differences:
It used ⌘⌥D for a keyboard shortcut
It will NOT prompt for confirmation, it will simply close and delete the current document.
I hope these are helpful! Tested on Mac OS X 10.13.6 with Keyboard Maestro 8.2.4
I like the thought of this, but I fear I would use it automatically too often and then suddenly want to undo which takes more time than just thinking properly in the first place!
property A : a reference to system attribute "KMVAR_AppName"
property application : a reference to the application named A
set D to my application's front document
set f to D's «class ppth» as POSIX file
tell application "Finder" to delete f
close D
if not (exists my application's document 1) then quit my application
I have this inside a macro group that makes it available only to specific applications (I trigger the macro with ⌘⌫, so didn't want it interfering with Finder, but it's a good idea to cordon off a macro of this nature anyway). As you can probably infer from the code, it's a general solution for multiple applications that are scriptable and expose their NSDocument object to AppleScript.
If you want to include the alert dialog before confirming to proceed with the deletion, then the tell application "Finder" line can be changed to:
tell application "Finder" to if the button returned of ¬
(display alert ("Really delete the following file?") ¬
message f's POSIX path ¬
buttons {"OK", "Cancel"} ¬
default button ("OK") ¬
cancel button ("Cancel")) ¬
= "OK" then delete f
The two lines following that close the document and exit the application if there are no open documents remaining, but will only execute if the user pressed "OK" on the alert, as pressing "Cancel" causes AppleScript to throw an error (intentionally), which we want.