Automatically open read-only files in View mode

When you open read-only files in Emacs, you probably won’t want to attempt to save them. Emacs will warn you if you try and help you deal with it. However, most of the time, it is interruptive to your flow to deal with it—most of the time, we never want to modify read-only files.

In that case, View mode will make it easier for you:

Toggle View mode, a minor mode for viewing text but not editing it.

When View mode is enabled, commands that do not change the buffer contents are available as usual. Kill commands save text but do not delete it from the buffer. Most other commands beep and tell the user that the buffer is read-only.

Enable it automatically with

(setq view-read-only t)

Via EmacsWiki!

In Bash—Pass Arguments From Function To Another

When I’m good about using and re-using functions in Bash I always end up passing arguments through from one function to another. For example:

function pie {
  open /Applications/Emacs.app --args --debug-init "$@"
}

function pienthm {
  EMACSNOTHEME=t pie --reverse-video "$@"
}

Horrible to admit but I keep forgetting the syntax even are taking copious notes on the GNU Bash manual.

BTW: hear, hear to including Bash-isms in every shell script!

(AppleScript+macOS) Maybe The Only Working Applescript For Toggling Grayscale And Inverting Colors On macOS Sierra In The World

2021-04-16: Here is one in JavaScript.

THANK YOU SILESKY

Toggle Grayscale

tell application "System Preferences"
  activate
  set the current pane to pane id "com.apple.preference.universalaccess"
  delay 1 # needs time to open universal access
  tell application "System Events" to tell process "System Preferences" to tell window "Accessibility"
    tell scroll area 2 to tell table 1 to tell row 6 #open display preferences
      select
    end tell
    click checkbox "Use grayscale"
  end tell
end tell

tell application "System Preferences" to quit

# Sierra: System Preferences -> Accessibility -> Display -> Use grayscale

Invert Colors

tell application "System Preferences"
  activate
  set the current pane to pane id "com.apple.preference.universalaccess"
  delay 1 # needs time to open universal access
  tell application "System Events" to tell process "System Preferences" to tell window "Accessibility"
    tell scroll area 2 to tell table 1 to tell row 6 #open display preferences
      select
    end tell
    click checkbox "Invert colors"
  end tell
end tell

tell application "System Preferences" to quit

# Sierra: System Preferences -> Accessibility -> Display -> Invert colors

Aliases

Run them from the command line. Maybe make your screen black and white at night or invert colors for screencasts or working in sunligh.

alias togglegrayscale=’osascript /Users/gcr/util/sspadtogglegrayscale.scpt’
alias invertcolors=’osascript /Users/gcr/util/sspadtogglecolors.scpt’