How to install new modes in emacs 23 on OS X? - macos

I just downloaded the Haskell and J modes off of SourceForge, and I'm having trouble figuring out how to make them interface with emacs 23. Google searches yield detailed instructions for emacs 22, but it looks like changes have been made that make it hard to figure out where I'm supposed to stick the source files. The internal documentation seems to assume more experience with emacs internals than I currently have, and the problem has resisted solution for several days. Does anyone know how to get these modes up and running?
EDIT: Thanks to Untwisted for supplying the answer. Ultimately, my real problems were these:
1) I didn't know that .emacs was invisible to the OSX finder but was visible through the terminal.
2) It never occurred to me that I could modify .emacs while an instance of emacs was running.
Once I realized that those were my problems, I used C-x C-f to open ~/.emacs, copied the text of Untwisted's fix, and modified it to reflect my personal file paths. After that, everything worked.

Basically you need to put the .el files somewhere (I keep mine in ~/.emacs_extras/haskell-mode/ ), and edit your ~/.emacs file to load Haskell mode when appropriate. Example of a ~/.emacs file:
(load "~/.emacs_addons/haskell-mode/haskell-site-file")
(add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode)
(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)
That should make Haskell mode work. For more details, other options, etc: http://www.haskell.org/haskellwiki/Haskell_mode_for_Emacs

Related

"File exists, but cannot be read", but third try is a charm (with emacs, os-x Catalina 10.15.6, dropbox smart sync)

I try to open a file using emacs c-x c-f /Users/fred/Dropbox/foo/bar/bam/baz.txt.
In the mini buffer it says...
"File exists, but cannot be read".
...Next I do m-x revert buffer. Now in the mini buffer it says....
"Opening input file: Input/output error, /Users/fred/Dropbox/foo/bar/bam/baz.txt"
...I do m-x revert buffer again and this time the file reads in fine.
The problem is that a file should open on the first try, no questions asked!
This is more or less a repeatable problem (specifically I have gotten "File exists, but cannot be read" several times in the last 2 weeks. I try various work arounds to open the file (e.g. hit m-x revert buffer twice as described above). I usually (always?) am able to open the file. And once I finally DO open one of those obstinate files, it easily opens using emacs in other contexts (e.g. new windows, or re-opens when I have closed the buffer).
<<< UPDATE ~2 DAYS AFTER ORIGINAL POST -- START OF SECTION >>
I seem to be able to reproduce a very similar behavior when I start emacs using an init file that starts an emacs with about 30 different text files open. (I.e. part of the init is to open these files in emacs). When I change the emacs buffer (c-x b) to point to some files, call them GoodFile1, GoodFile2, there text is visible, i.e. all is well. For other files, call them BadFile1, BadFile2, BadFile3, when I switch to them the screen is blank and I know they have LOTs of text in them. I haven't seem any error messages akin to "File exists, but cannot be read", but still this is bad behavior and it seems related to the original problem. Next, similar to the originally reported case, I hit m-x revert buffer between 1 and 4(?) times and, poof!, the text appears and I am begrundgingly happy again. Now, here's the interesting bit: when I start a new terminal window and fire up an emacs loading the same init file then the formerly bad files (e.g. BadFile1, BadFile2, BadFile3) are now visible right from the start -- as they should be on a normally functioning computer. It is as if a formerly blank seeming file changes some sort of state so that when a fresh emacs tries to open it the file shows up as it should. What kind of state change is involved? I think it has to do with smart sync. So the question is, assuming it is smart sync, how to avoid this annoying required behavior of hitting revert buffer a buncha times? Does it last between boots? I am pretty sure unix touch did not help. Maybe there is some other operation to perform?
Note: On this machine I always start emacs with 'emacs -nw -l my_special_emacs_init.el' (GUI's are for wimps (-;)
<<< UPDATE ~2 DAYS AFTER ORIGINAL POST -- END OF SECTION >>
All annoying bad behavior happens on my new set up.
On my old setup, I have never gotten any thing like this behavior over years, possibly decades. (and, on my old setup, I tried the specific file mentioned above and it opened fine)
So, what, you may ask, is different between my new setup and my old setup?
OS / Hardware:
New Setup: Catalina 10.15.6 on a brand new Mac Book Pro.
Old Setup: Mohave 10.14.6 on a Mac Book Pro "early 2015" (and has never had this issue in prior OS's either)
Dropbox:
New Setup: Smart Sync On. I am using Dropbox with Smart Sync Turned on such that files are by default "online only". "online only" is a misnomer. Some files end up locally on my hard drive. Smart sync seems to figure out what files to store locally on the mac. I suspect that knowing how it does this will fix my problem.
Old Setup: Smart Sync Off. I have been using Dropbox for years but have stayed far away from Smart Sync and have never had a problem opening a file.
Emacs Version:
New Setup: GNU Emacs 27.1
Old Setup: GNU Emacs 22.1.1.
Clearly it can't be a permissions issue bc I've never had this problem on my old setup.
Any clues?
Does anyone know of any diagnostics I can do to "dig under the hood" when I find another case of this "File exists, but cannot be read".
Any thoughts on whether it is OS difference? Hardware difference? Dropbox Smart Sync Yes vs Smart Sync No difference? Emacs version difference?
<<< UPDATE ~2 DAYS AFTER ORIGINAL POST -- START OF SECTION >>
My current hunch is the the 'state change' mentioned in the update above is related to smart sync somehow figuring out that the user wants a given file cached locally. The bad behaving files are non-local so poor emacs can't open them. Whacking them with 1 to 4 revert buffers tells smart sync to make the given file local. Alas, smart sync is not smart enough to figure out what emacs users want right off the bat! Perhaps emacs can be changed in such a way as to tickle smart sync into realize that the given file should be made local local Or we can petition Dropbox to respect emacs. Or I am not using smart sync correctly. Thoughts?
<<< UPDATE ~2 DAYS AFTER ORIGINAL POST -- END OF SECTION >>
I had the same problem. This is the root cause, and solution:
https://emacs.stackexchange.com/questions/53026/how-to-restore-file-system-access-in-macos-catalina
In short, give /usr/bin/ruby full filesystem access in General Settings -> Security & Privacy -> Privacy
I had this problem on Big Sur; giving Full Disk Access to /usr/bin/ruby solved the problem.
Note it is not so trivial to do this, you have to press cmd-shift-dot in the system preferences file chooser to enable the usr directory to be visible at the Macintosh HD level.

Vim and MacVim questions

Greetings fellow problem solvers.
I'll start by saying my level of expertise regarding coding/anything compsci is somewhere right above ZERO (intro to java last semester & currently teaching myself python, but that's it). Also I have a macbook air running 10.14.6(mojave). Ok, here are my questions.
What I did:
I installed macvim version 8.1.2234 before realizing my machine was shipped with vim 8.0.1365 preinstalled. I installed macvim using the download .dmg & "drag/drop to applications" method.
What I'd like to know:
Firstly, MacVim and Vim appear to be separate programs (when I type mvim -v as opposed to vim -v in the terminal, each one shows a different version number as described above). So, how can I remove/replace/update/overwrite or whatever, so that I only have either macvim or vim? I don't really care which one I have as long as I only have one
--> Before telling me to just rename an alias so that one maps to the other, please read the info below <--
I REALLY don't want two nearly identical programs on my computer because, a)it seems like a waste a space b)don't want the possibility of accidentally saving something to the wrong place, or calling something from the wrong place, but mostly c)so I can sleep at night.
That being said, do I NEED both? Does macvim rely on vim to work or do they both exist and work independently? Also does renaming an alias mean that the other will be replaced? Because I would assume that just renaming one would be a lot like having two houses, but making both driveways only go to one house.
Additional info: I have do homebrew but I didn't install macvim using homebrew. I found another post recommending to use (i don't remember exact syntax but something like..) $brew overwrite vim--with-macvim. So I thought great, I'll uninstall macvim since I haven't used it at all yet, and then I'll re-download using the homebrew overwrite method. But then I read that it's a little more complicated than moving the "Vim" folder to the trash, and after two unsuccessful attempts in the terminal that looked like this:
$brew uninstall mvim (throws no keg error)
$brew uninstall macvim (same error)
I decided to reach out for help before I break anything.
Thanks in advance for any info/advice, it is much appreciated!
I don’t have time for a longer explanation at the moment, but:
Breathe Easy
MacVim is nearly completely independent from (terminal) vim. They do share your vimrc, but MacVim also reads gvimrc, and uses its own runtime directories.
You’re not wasting much space, and it would be a Bad Idea™️ to mess with the system installation of some programs.

Postgres.App installation

this is probably a total newbie question but try as I might, I cannot seem to get my terminal to recognize the psql command. So far, I have tried the following:
Added PATH="/Applications/Postgres.app/Contents/Versions/9.3/bin:$PATH" to my .profile file, saved, and reopened terminal. No luck. (Path that is given in the Postgres.App installation instructions on their site.)
Added PATH="/Applications/Postgres.app/Contents/Versions/9.3/bin:$PATH" to my .bash_profile file, saved, and reopened terminal. No luck. (Tried another file to be sure.)
Added export PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH" to my .profile file, saved, and reopened terminal. No luck. (Recommended in another question asked here on Stack.)
Same deal as previous but in .bash_profile. No luck.
Same deal but with /Users/my_user/Library/Application Support/Postgres/var-9.3 in both .profile and .bash_profile. No luck. (Data directory given in the app preferences, running out of ideas.)
What am I missing? This shouldn't be this hard. Thanks for the help!
Okay, so it never ceases to amaze me how much is knowledge is assumed by the courses, programs, and even installation instructions dealing with unix based systems. Like I thought, it was a silly issue.
I've heard repeatedly and from multiple sources that to make sure changes are applied, restart your terminal. Well, in this case, that is not enough. If you find yourself in the same situation, you must either restart your computer or (and much more simply) issue the following command in terminal:
source ~/.bash_profile
While a silly little issue, ignorance doesn't care and your stuff won't work until eradicate said ignorance. The good thing is that with each new hard won gem of knowledge, that's one more thing I won't forget anytime soon and insight into how to better diagnose future problems.

How can I most effectively use Emacs as an editor alongside XCode?

There are a few tutorials online (For example) having to do with configuring emacs to work with XCode, but they all seem to be for old versions, and I haven't found one that ties neatly to XCode 3.x + Emacs 23.1 in a way that I can unpack.
So, I'm running XCode 3.1.2 and the Mac Cocoa application build of Emacs 23.1. I have a passing familiarity with elisp, so modifying configurations doesn't scare me, particularly. I'd like to be editing my Objective-C code in Emacs, because the XCode editor is painful once you've used a real text editor (snark, snark).
What should I do to make this happen?
For Emacs.app you can adopt a cleaner approach, and it doesn't require you to change configurations (unless you don't like make-frame to be called when a file is opened from XCode, but it's very easy to change).
Well, the customization should be similar to the documentation you pointed to. With Emacs 23, the server/client code has changed just a little. Namely, you can start it with the [--daemon][1] option to have Emacs start a server in the background. Then, have XCode just call Emacs using [emacsclient][2]. There are options you can use with emacsclient to force a new frame (graphical window): -c, and you can even start it off with -a to ensure you get an emacs if you forgot to start it with --daemon.

How do I open files over FTP with Emacs 22.2.1 on Windows?

AngeFtp? EFS?
Is there a better option?
Is the preferred option built-in?
If so, how do I turn it on?
If not, where do I download it?
I tried with AngeFtp, just by doing find-file using a filespec like
/name#server:/directory
and it prompts me for a password, then does the login to the FTP server and gets the contents - it takes a while - but when it finishes, I don't get or see a dired buffer. I just get a blank buffer with a weird name.
Tramp is the modern replacement for ange-ftp.
The short version is, you specify a file like "/myusername#host:path/to/file". Works like a charm.
View the linked documentation for installation instructions, though it might already be installed if you have a fairly new installation of emacs. Also, there are several questions related to tramp and remote development with emacs on SO
I just use C-x C-f or C-x C-d, with the remote-file format /host:/path/to/my/dir/. And I customize tramp-default-method to "ftp". Works like a charm. When it opens the connection for the first time (only), it prompts for the password.

Resources