AppleScript in Automator broken in Big Sur - applescript

So, I had a pretty simple Automator task that I used from the 'Services' right-click pop-up menu in Finder that copied an image, renamed it, scaled it, then added a border around it. Worked fine for ages. The final step of it is to do the padding in an AppleScript, which starts with this incantation:
on run {input, parameters}
set this_image to item 1 of input
...
And is meant to continue with this_image set to the file path from the previous step.
Since Big Sur, I get an error
The action “Run AppleScript” encountered an error: “Can’t get item 1 of {}.”
Which seems to indicate that input is now an empty list. So — perhaps the previous action (Rename Finder Items: Replace Text) does not pass a result — or something else.
Quick search via Google does not yield any clues, except some indication that breaking changes are part of the game and Apple doesn't really indicate what would break.
Any ideas? Every other step works fine — as I single-step, the file is manipulated as expected (duplicated, renamed, scaled, etc.). It's only when it gets to this line where I expect to have a filename in order to do the padding that there's an issue.
(Also, just in case someone wants to suggest using the 'Pad Images' automator action — the padding it performs isn't my kind of padding — it puts padding around the entire image. I just put padding at the top and bottom turning a 3x2 image into a square with the image proper sandwiched between white borders, top and bottom.)

The issue appears to be at one particular text replacement step, where I attempt to replace a string with a leading space with an empty string. For some reason, that fails — I am not sure why. But, when I change that particular step ('Rename Finder Items: Replace Text') to replace any string with a leading space with another character (say, an '_') it works fine. So I am deducing that replacing something with an empty string is the culprit, but I'm not 100% sure. But, now my Automator workflow works having adjusted that particular step.

Related

I can't enter text via the command line, is it possible to do this?

When you try to automatically enter the desired content (and there will be a lot of such objects with text content and I would prefer to avoid entering all the necessary data manually), the input field moves from the console to the area highlighted with a red rectangle, which makes it impossible to automatically create signatures.
The question is, is it possible to make the input field of the desired content always remain on the command line?
enter image description here
I tried to find the question on the Internet by entering the corresponding queries in Russian, nothing gave results
I understand that by "automatically" you mean copying and pasting from some editor to the AutoCAD command prompt.
I will never work that way, you must use a programming language and I think the easiest thing is to use AutoLISP.
Try copying and pasting this:
(command "_mtext" "36,0" "42,0" "your text here" "")
and note the empty string at the end "" that finalises the MTEXT command.

GREP for end of text symbol

I need to go through and join hundreds of separate text frames into a unified text thread. The problem is that when I link the frames the style of the first paragraph of the frame I'm linking to ofter changes to the style of the last paragraph in the text frame I'm linking from. If I could put a frame break into the end of every text frame I could avoid this problem. The hidden character for 'end of text' looks like a hashtag. Is there a GREP for this?
Just found on the Adobe forums that \z is the character I want, and it does find all the instances, but when I try to change them for page breaks I crash my programme. Every damn time.
You can't only search for a single location placeholder with InDesign's GREP (it has its wings clipped) – although it should not have made it crash. Change the Keep Settings for every first paragraph in your stories to start in a new frame, it'll have the same result when joining.
You can use GREP for this as well. Search for
\A.
and leave the Change To field blank. In the Change To formatting field, set your new Keep options. \A matches Start of Story, and the single . is so you actually can find a (any) character so it won't crash on you again.
So I did this in the end which achieved what I wanted:
Find: (.)(\z)
Change to: $1~R
This way when I linked the text frames the styles didn't get changed.
Thanks for everyone's help, esp. user1754036 for the link to InDesign Secrets which really solved the puzzle for me.

How to convince NSTextView that text starts at the bottom?

I will append some strings to NSTextView, but I want them to start at the bottom. New appended string should go underneath the last appended string.
In Java or C#, one can set VerticalAligment = bottom, but I can't find any appropriate way to achieve this in Cocoa... Any thoughts?
EDIT:
I guess I didn't specify precisely enough what I want, so I'll append two pictures. First is what it looks now, second one is what I want. Basically, the newest string is always at the bottom and the older ones gets pushed up. Makes sense now?

Can I make emacs grep windows just use the other window to open files in?

I've got emacs in front of me.
I've run a find-grep, and it's got many hits, which are displayed in a window. The file names are displayed in green as hyperlinks.
I make that the only window, with C-x 1.
If I click on a file name, the window splits vertically, and the file with the found text is displayed in the other window.
If I click on further filenames, then the new file replaces the old file, which is what I want to happen.
So far, so good...
However if I resize the windows, then emacs will periodically (when I click) split one of the two windows again, rendering the display difficult to read. It will then cycle opening new files between the two new windows. Occasionally it will open more windows and make the situation worse. If I close any of these new windows they just get reopened again.
In fact sometimes this perverse behaviour happens even if I don't resize anything. It just seems to happen more often if I do.
I would like emacs to stop buggering around and just have one find-grep window and one 'display' window, and always replace the display window with the new file. I would also like to be able to set these windows to the sizes that seem most convenient.
Is there any way to achieve this?
Or can anyone point me to an essay on how the whole (replace the contents of this window/replace the contents of a different window/create another window by splitting) thing works, so I can go and hack it sane.
Short fix:
Try doing this
(setq split-height-threshold nil
split-width-threshold nil)
This will prevent Emacs from splitting windows automatically (horizontally or vertically). This might be undesirable in other situations, but this should do the job. Try it for a week or so and see if it disrupts your flow.
Also, I found that if the point was in one of the windows, and I clicked on a link, the file opened up in the next window (if any).
So, if you want to make the file open in the right window (when you have more than one window), you can ensure that the point is in the window before the window you want.
Longer answer:
OK. I was able to reproduce the problem. The thing is the window showing the files is pretty big (wide or tall) because you resized it and Emacs sees that the width or height is greater than the respective threshold and splits it likewise. So, we have to either make the threshold higher or disallow the behaviour completely.
And, just to answer the last few questions:
To get current window - (selected-window)
To get next window - (next-window)
To select a window - (select-window foo-window)
To get the buffer of the current window - (current-buffer)
To get the buffer of some window - (window-buffer foo-window)
To set a buffer for a window - (set-window-buffer foo-window bar-buffer)
I'm sure you can hack together decent window/buffer management functions using these functions.
You can use C-h f to get more details on each of these functions.
Also check out the Elisp manual - http://www.chemie.fu-berlin.de/chemnet/use/info/elisp/elisp_26.html

Fastest way to "jump back" to a file in TextMate?

Often, when I am reading code or debugging, I want the ability to quickly jump around files. I especially want to "go back" to where I was. I know about "Command+T", "Command+Shift+T", and, bookmarks. But, I cannot figure out a way to jump around files quickly.
UPDATE: I do not think I my question was clear enough judging by two answers given. Specifically, I am looking for a way to "jump back" to where I was in a file. I know how to navigate in TextMate (in general). I want to know if TextMate has a "jump back" key binding.
It's subtle.
The command-T thing has the files listed in Most Recently Used order.
So, you can go command-T return to get back to your last file real quick. At first I couldn't find it either.
I don't think there's a go to last edit location as there is in, say, IDEA/RubyMine.
Courtesy of MacroMates.com
2.3 Moving Between Files (With Grace)
When working with projects there are a few ways to move between the open files.
The most straightforward way is by clicking on the file tab you need. This can also be done from the keyboard by pressing ⌘1-9, which will switch to file tab 1-9.
You can also use ⌥⌘← and ⌥⌘→ to select the file tab to the left or right of the current one.
It is possible to re-arrange the file tabs by using the mouse to drag-sort them (click and hold the mouse button on a tab and then drag it to the new location). This should make it possible to arrange them so that keyboard switching is more natural.
One more key is ⌥⌘↑ which cycles through text files with the same base name as the current file. This is mainly useful when working with languages which have an interface file (header) and implementation file (source).
When you want to move to a file which is not open you can use the Go to File… action in the Navigation menu (bound to ⌘T). This opens a window like the one shown below.
Go To File
This window lists all text files in the project sorted by last use, which means pressing return will open (or go to) the last file you worked on. So using it this way makes for easy switching to the most recently used file.
You can enter a filter string to narrow down the number of files shown. This filter string is matched against the filenames as an abbreviation and the files are sorted according to how well they match the given abbreviation. For example in the picture above the filter string is otv and TextMate determines that OakTextView.h is the best match for that (by placing it at the top).
The file I want is OakTextView.mm which ranks as #2. But since I have already corrected it in the past, TextMate has learned that this is the match that should go together with the otv filter string, i.e. it is adaptive and learns from your usage patterns.
If you have a project window open, you can leave frequently-accessed files open (in tabs), and then use ⌘+1-9 to jump to open tabs.

Resources