Why does the "Open in Marked" service open TextEdit?

Chris Lawrence

20 Sep, 2011 08:05 AM

I can't really tell if this is a bug or not, but whenever I use the Open in Marked service from any editor it also opens TextEdit. I've had a quick look through the Automator workflow and I can really figure out a reason for this.

It's only slightly annoying, but I'm curious as to what is happening or if anyone else experiences the same thing.

1. Support Staff Posted by Brett on 20 Sep, 2011 10:42 AM

Hi Chris,

2. Posted by Chris Lawrence on 20 Sep, 2011 11:27 AM

3. Posted by Chris Lawrence on 20 Sep, 2011 11:35 AM

4. Support Staff Posted by Brett on 20 Sep, 2011 12:18 PM

The "Open Current File in Marked" service found here?

5. Posted by Chris Lawrence on 20 Sep, 2011 12:26 PM

6. Support Staff Posted by Brett on 20 Sep, 2011 12:31 PM

Did you delete the previous version before installing the new one? In your title you reference "Open in Marked," which is not the service that's included in that pack. "Open Current File in Marked" is, and I can verify that the bug is not in that file (just downloaded and checked).

7. Posted by Chris Lawrence on 20 Sep, 2011 02:24 PM

I am definitely using the most current version of "Open Current File in Marked". I just deleted the old Service, restarted, and copied the new one in and I'm still getting TextEdit opening.

Here is the AppleScript in the service:

-- Open in Marked
-- Attempts to open the currently-edited document in Marked for previewing
-- By Brett Terpstra <http://brettterpstra.com>
-- for Marked <http://markedapp.com>
-- Based on ideas by Lri <https://gist.github.com/1077745>
-- with contributions from Donald Curtis <https://github.com/milkypostman>

on run {}
tell application "System Events"
set frontApp to (name of first process whose frontmost is true)
end tell
tell application frontApp to activate
set f to false
set flist to {}

--Marked (if Marked is foreground, hide Marked and end script)
if frontApp is "Marked" then
tell application "System Events" to set visible of process "Marked" to false
return
--Notational Velocity/nvALT
else if frontApp is "Finder" then
tell application "Finder" to set flist to (get selection)
-- Emacs?
else if frontApp is "Emacs" then
set emacsclient to false
tell application "Finder"
if exists POSIX file "/usr/local/bin/emacsclient" then
set emacsclient to "/usr/local/bin/emacsclient"
end if
end tell
if emacsclient is not false then
set f to do shell script emacsclient & " -e '(first (delete nil (mapcar (function buffer-file-name) (buffer-list))))' | sed 's/^\"//' | sed 's/\"\$//'" as string
if f is not "nil" then
set f to f as POSIX file as alias
else
set f to false
end if
end if
--Byword (open current document)
else if frontApp is "Byword" then
tell application frontApp to set f to file of document of window 1 as alias
else if frontApp is "TextEdit" then
tell application "TextEdit" to set f to path of document of window 1 as POSIX file
else
tell application "System Events"
tell process frontApp
try
set isScriptable to has scripting terminology
on error
set isScriptable to false
end try
end tell
end tell
if isScriptable then
try
tell application frontApp to set f to POSIX file (path of document 1 of window 1) as alias
end try
if f is false then
try
tell application frontApp to set f to POSIX file (path of first document) as alias
end try
end if
if f is false then
try
tell application frontApp to set f to POSIX file (text 17 thru -1 of (get URL of document 1)) as alias -- BBEdit
end try
end if
end if
end if

if f is false and flist is not {} then
tell application "Marked"
activate
repeat with afile in flist
open (afile as alias)
end repeat
end tell
else if f is not false then
tell application "Marked"
activate
open f
end tell
end if
end run

8. Support Staff Posted by Brett on 20 Sep, 2011 02:55 PM

I'm honestly not sure why this would be happening. It was a bug (stupid mistake) that I left in the first version I released, but it's since been fixed. I've tested locally and have reviewed the script you just posted for mistakes, and both seem to check out fine... if you can find anything else that might be overriding the service in the Service Menu, but I doubt that's the case. Are you triggering the Service manually or via a shortcut?

Do you have something like FastScripts where you could pull the AppleScript out, assign a shortcut key to it and trigger it to see if you get the same result? Or even just run it from AppleScript Editor and see if TextEdit opens?

9. Posted by Chris Lawrence on 21 Sep, 2011 11:10 AM

I'm really sorry, I have wasted way too much of your time on this. I have just started using the Applescript instead with a Quicksilver trigger and it works exactly the same. I'm assuming there's something janky going on with my system.

Thanks,
Chris

10. Brett closed this discussion on 21 Sep, 2011 08:41 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help Blurs the current field

Comment Form

r Focus the comment reply box Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

 21 Feb, 2020 11:32 PM Option to use MathJax 3? 20 Feb, 2020 03:12 PM Regular crashes 13 Feb, 2020 09:22 PM Markdown Formatting 11 Feb, 2020 11:53 AM Custom themes not working 10 Feb, 2020 06:48 PM KaTex Preview Update

Recent Articles

 Using JavaScript in Marked Custom CSS: Writing custom CSS for Marked License code has already been utilized Highlight sentences longer than a certain number of words How do I retrieve a lost license (direct version)