Posts

How to open file in some applicationl with AppleScript

The one way is: set the_application to path to application "TextEdit" tell application "Finder" open the_file using the_application end tell but the best seems to be: set f to choose file of type "TEXT" tell application "Finder" set a to application file id "com.apple.TextEdit" open f using a end tell

EMACS HOOKS FOR SWITCHING HEADER TO PROPER MODE

;; C-HOOK FOR SWITCHING HEADER TO PROPER MODE (defun u:objc-h-match () (and (string-match "\\.[hH]$" (buffer-file-name)) (string-match "^\\(@\\|#import\\)" (buffer-string)))) (defun u:c++-h-match () (and (string-match "\\.[hH]$" (buffer-file-name)) (string-match "^\s*\\(class\s*.*\\(\s*:\s*public\\|protected\\|private\\)?\\)\\|\\(public\\|protected\\|private\\):\\|\\ \\|\\ " (buffer-string)))) (push '(u:objc-h-match . objc-mode) magic-mode-alist) (push '(u:c++-h-match . c++-mode) magic-mode-alist)

How To Get a List of Keyborad Layouts using F-Script

Inject F-Script into System Preferences with F-Script Anywhere. Switch to International ->Input Menu. From FSA menu create a new workspace and then from that workspace open a browser for the list of layouts (that is an object of the NoSelectionTableView class) and name that object and its data source (IntlKeyboardDataSource). In the script below I use the 'tview' and dsrc' names correspondingly. > str := NSString new. > 0 to: ((tview numberOfRows) - 1) do: [ :i | |name| ((dsrc isInputMethodForRow: i) | (dsrc isKeyboardRow: i)) ifTrue: [ name := dsrc resNameForRow: i. name ~~ nil ifTrue: [ str := str ++ name ++ '\n' ]]] >str writeToFile: '/Users/sasha/tmp/Layouts' atomically: false.

Folder Action to create TODAY folder

The script below, if used as Folder Action Script, will authomatically create a folder with the current date as a name and link to it named _Today in every folder for which the corrspondent action is activated. To use it put it in the ~/Library/Scripts/Folder Action Scripts/ folder on opening folder this_folder set tf_path to POSIX path of this_folder set dt to tf_path & "/" & (do shell script "date +%Y-%m-%d") set TODAY to tf_path & "/_Today" do shell script "DT=\"" & dt & "\" ; TODAY=\"" & TODAY & "\"; if [ ! -d $DT ] ; then mkdir $DT ; pwd > ~/aaa; else pwd > ~/aaa ; fi; if [ -h $TODAY ] ; then rm $TODAY ; fi; ln -s $DT $TODAY;" end opening folder

Back To Etags

In my previous post I wrote about using exuberant-ctags for emacs and Objective-C. But for some reason exuberant-ctags failed to create tags for funcions in /usr/include/string.h on my Mac. So, I switched back to etags. Here the correspondent shell script for generating tags for system headers on Mac OS X: #!/bin/sh s="\t " S="[$s]*" w="_a-zA-Z0-9" CN="[A-Z][$w]*" NM="[$w][$w]*" ETAGS="/Applications/Emacs.app/Contents/MacOS/bin/etags" cat /dev/null > tmp.tags find /usr/include -name "*.h" -exec \ $ETAGS -a --declarations -o tmp.tags \ "{}" ";" mv tmp.tags include.tags cat /dev/null > tmp.tags find /System/Library/Frameworks -name "*.h" -exec \ $ETAGS -a --declarations -o tmp.tags \ -r "/$S[-+]$S(\($S$NM\)\{1,3\}$S\**$S)?$S\($NM\)$S[:;]/\2/" \ "{}" ";" sed "/^@class/d" tmp.tags > Frameworks.tags rm tmp.tags

Using Exuberant Ctags with Emacs And Objective-C

Below is a small script that generates Emacs tags files for the header files in /System/Library/Frameworks and /usr/include on Mac: #!/bin/sh s="\t " S="[$s]*" w="_a-zA-Z0-9" CN="[A-Z][$w]*" NM="[$w][$w]*" cat /dev/null > tmp.tags find /usr/include -name "*.h" -exec \ ctags -e -a -o tmp.tags "{}" ";" awk -v LINE="" ' { if (LINE != $0) {LINE = $0; print $0;} }' tmp.tags > include.tags cat /dev/null > tmp.tags find /System/Library/Frameworks -name "*.h" -exec \ ctags -e -a -o tmp.tags \ --regex-C++="/^@(interface|protocol)$S($CN($S\($CN\))*)/\2/c/" \ --regex-C++="/^$S(\-|\+)$S\($S$NM($S$NM)*$S\**$S\)*$S($NM)$S[:;]/\3/f/" \ "{}" ";" awk -v LINE="" ' { if (LINE != $0) {LINE = $0; print $0;} }' tmp.tags > Frameworks.tags rm tmp.tags