0

I'm using the railwaycat/emacs-mac-port, and would like to continue use it because of the very nice smooth scrolling. Anyone knows if there is a way to have the "M-s-h" key work as in other Mac applications? In Cocoa emacs I can for example do (global-set-key (kbd "M-S-h") 'ns-do-hide-others). Thanks

  • Do the functions themselves -- ns-do-hide-others and/or ns-do-hide-emacs -- work if you call them interactively? M-x ns-do-hide-others and M-x ns-do-hide-emacs. [Although not related to your issue, smooth scrolling is as simple as (setq scroll-conservatively 101) in a generic Emacs without any other settings needed. Most newbies add other stuff that makes it not work correctly.] When building Emacs with the option --with-ns, the library ns-win.el is used/incorporated and it has those two functions, plus a slew of super keybindings. – lawlist Jun 8 '15 at 3:38
  • Hi and thanks for the answer. The railwaycat/emacs-mac-port does not have the ns- functions. I tried to reinstall it with brew install emacs-mac --with-ns but the functions are still not available. It seems like my question really is how to get the ns- functions available in this Emacs port! – Robert Jun 8 '15 at 5:59
  • You may wish to consider modifying the question to attract someone familiar with building this particular port of Emacs. The option/flag --with-ns is used when building the vanilla/generic version of Emacs from source. I don't use brew because it puts things in different places, and I want everything in one folder so I can rsync everything to different computers and backup to different storage locations (e.g., remote and usb). – lawlist Jun 8 '15 at 7:04
1

Try this.

(setq mac-pass-command-to-system nil)
1

Yes, you can use the do-applescript command with some AppleScript to hide all other applications:

(defun mac-hide-others ()
  "On a Mac, hide all applications other than Emacs."
  (interactive)
  (do-applescript (concat "tell application \"System Events\" to "
                          "set visible of every process whose visible is true "
                          "and name is not \"Emacs\" to "
                          "false")))

If you don't want the frontmost application to be hidden (in case you are calling the command from a terminal emulator, for example, and you do not want the terminal to be hidden after executing the command), then use this slight modification:

(defun mac-hide-others ()
  "On a Mac, hide all applications other than Emacs and the frontmost
application."
  (interactive)
  (do-applescript (concat "tell application \"System Events\" to "
                          "set visible of every process whose visible is true "
                          "and name is not \"Emacs\" "
                          "and frontmost is false to "
                          "false")))

To call either of these functions with "M-s-h", use

(global-set-key (kbd "M-s-h") 'mac-hide-others)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.