cannot open Singular on a running emacs - macos

I am a newbies in Singular. I just downloaded Singular4-0-2_64.dmg, mounted the image, right-ckick, show the package contents, then moved the contents folder to the Applications directory. double-clicking Contents/MacOS/Singular (or Esingular) I have Singular running in a terminal (or via emacs in a terminal). But when I try M-x singular in a running emacs, it says "cannot open load file : no such file or directory, singular".
Then I copied .emacs-general and .emacs-singular to the home directory. Adding the following lines to .emacs
(setq load-path (cons "" load-path))
(autoload 'singular "singular"
"Start Singular using default values." t)
(autoload 'singular-other "singular"
"Ask for arguments and start Singular." t)
changing singular-emacs-home-directory into /Applications/Singular.app/Contents/share/singular/emacs/ it still doesn't work.
Also when I replace .emacs with .emacs-singular, replacing the above directory, it gives the error:
Warning (initialization): An error occurred while loading `/Users/Me/.emacs':
Symbol's value as variable is void: /Applications/Singular.app/Contents/share/singular/emacs
Am I not finding the right singular-emacs-home-directroty or is there any other problem?
I appreciate your help.
Also I must mention that I am a user of emacs for Macaulay2. For that I have changed .emacs and .emacs-Macaulay2 in order to teach emacs where to look for M2. Is there anything similar to be done for Singular? Shall I have a file .emacs-singular somewhere?
Thanks for your help.

Here are some basic settings that assume the Singular.app has been installed to the /Applications folder. I chose to set the absolute path to the executable, instead of setting the PATH in Emacs. The PATH in Emacs on OSX is (by default) not the same as what one would generally except to see in let's say Terminal.app. [But, setting the PATH is beyond the scope of this basic answer.]
My personal preference is to have all of the lisp and configuration files in a custom directory for purposes of editing and backup up. This limited example just leaves everything where they are.
In the Emacs master branch (February 7, 2016), there is no built-in variable named current-menubar -- the configuration files are looking for the existence of that variable. I did not spend the time to debug the built-in configuration files to find out what version of Emacs they were designed for, and I did not spend the time to make the Singular elisp libraries compatible with the latest Emacs master branch.
Add the following lines of code to the .emacs file in the home directory, save the file, and restart Emacs. Then type M-x singular RET
(add-to-list 'load-path "/Applications/Singular.app/Contents/share/singular/emacs/")
(require 'singular)
(setq singular-emacs-home-directory "/Applications/Singular.app/Contents/share/singular/emacs/")
(defvar current-menubar nil)
(setq singular-executable-default "/Applications/Singular.app/Contents/MacOS/Singular")
(load-file "/Applications/Singular.app/Contents/share/singular/emacs/.emacs-general")
(load-file "/Applications/Singular.app/Contents/share/singular/emacs/.emacs-singular")

Related

Where is my .emacs file on Mac OS X

so i am trying to add the google go module to my .emacs file so that when I use emacs to edit my .go file it will have the appropriate indentations and highlight of the words. Ive looked online and it seems that I need to add the following code snippets to my .emacs file (which i cannot find!)
;; go mode
(setq load-path (cons "/usr/local/go/misc/emacs" load-path))
(require 'go-mode-load)
I have put go-mode-load.el and go-mode.el in my .emacs.d/ directory I believe i still need to find the .emacs file to add the code listed above I am running OS X if this helps. Can someone help me get this working thank you!
Eval this with M-: (find-file user-init-file)
Emacs will then open what it considers your user initialization file.
I have
(global-set-key (kbd "<f12>") (lambda () (interactive) (find-file-other-window user-init-file)))
in my .emacs so that i can easily edit this.
The Emacs manual tells you:
This file, if it exists, specifies how to initialize Emacs for you.
Emacs looks for your init file using the filenames `~/.emacs', `~/.emacs.el',
or `~/.emacs.d/init.el'; you can choose to use any one of these three
names. Here, `~/' stands for your home directory.
Most people use ~/.emacs, I think. Just do C-x C-f ~/.emacs to create it if you do not yet have one.

Can't find git executable

I'm using Emacs 24 on OS X 10.6.8. Doing magit-status says
Searching for program: no such file or directory, git
However, the Emacs shell is able to find git, so this does not seem to be a $PATH issue. What else could it be?
Try checking the value of exec-path variable. This controls the directories which are looked by Emacs for external executables (including git).
This is a customizable variable, and you can add the path to git to the list of existing directories.
I have the elisp snippet in my .emacs.d/init.el file for my Emacs install under OSX, which sets both the PATH and exec-path correctly.
;;; Set localized PATH for OS X
(defun my-add-path (path-element)
"Add the specified PATH-ELEMENT to the Emacs PATH."
(interactive "DEnter directory to be added to path: ")
(if (file-directory-p path-element)
(progn
(setenv "PATH" (concat (expand-file-name path-element) path-separator (getenv "PATH")))
(add-to-list 'exec-path (expand-file-name path-element)))))
(if (fboundp 'my-add-path)
(let ((my-paths (list "/opt/local/bin" "/usr/local/bin" "/usr/local/git/bin")))
(dolist (path-to-add my-paths (getenv "PATH"))
(my-add-path path-to-add))))
Emacs on OS X uses the system-wide environment variables, which can be overridden by creating a magic environment.plist XML file in the right directory. A better solution, though, is to have Emacs copy the value of $PATH from your shell, so that it matches what you see in Terminal.app.
#Anupam's answer is based on a snippet of code which I originally wrote for this purpose, but I've now improved that code and published it as a little elisp library called exec-path-from-shell which you can install from Marmalade or Melpa.

Setting up .emacs file for mac ruby development

I am having a difficult time loading ruby-mode in emacs on my mac.
The .emacs file is located at ~/.emacs I've added several commands to it (many pasted from this site) and none seem to get loaded. Any advise? I"m not sure if the file isn't loading or I have the command syntax wrong.
All I need is the following
4 space indent (auto-intedent would be great as well)
ruby mode loaded for .rb files.
Thanks!
Put the line (warn "Loading .emacs") as the first line of .emacs. When you start emacs does it show you that message in a warning buffer? If so, it at least started loading the file.
If this does nothing, try opening the file in emacs, and running M-x eval-buffer.
Also, at startup, does the Messages buffer indicate any errors in your .emacs? This is the most common reason for a .emacs not to take effect.
This is how emacs finds the .emacs file.
57.6.4 How Emacs Finds Your Init File
Normally Emacs uses the environment variable HOME (see HOME) to find .emacs; that's what ‘~’ means in a file name. If .emacs is not found inside ~/ (nor .emacs.el), Emacs looks for ~/.emacs.d/init.el (which, like ~/.emacs.el, can be byte-compiled).
However, if you run Emacs from a shell started by su, Emacs tries to find your own .emacs, not that of the user you are currently pretending to be. The idea is that you should get your own editor customizations even if you are running as the super user.
More precisely, Emacs first determines which user's init file to use. It gets your user name from the environment variables LOGNAME and USER; if neither of those exists, it uses effective user-ID. If that user name matches the real user-ID, then Emacs uses HOME; otherwise, it looks up the home directory corresponding to that user name in the system's data base of users.
From http://www.gnu.org/software/emacs/manual/html_node/emacs/Find-Init.html#Find-Init

Text editor / IDE for Ruby similar to DrScheme

For those who haven't used DrScheme, window is split in two parts: one part is a file you're editing, and the other is interactive shell. When I run a file, it is loaded into interactive environment, so I can invoke functions I've defined etc. Interactive environment still has all the features of text editor (syntax highlighting, auto completion, etc...)
So is there an IDE for Ruby that doesn't just execute script I'm making, but loads it into irb instead, with all text editor goodies?
This exact request (even up to the fact that Dr Scheme motivated it) is what finally pushed me to learn Emacs.
Here's what i did to install it under Windows Vista:
Download Emacs from http://ftp.gnu.org/gnu/windows/emacs/emacs-22.3-bin-i386.zip
Unzip it to the directory of your choice
After unzipping it create an includes directory anywhere you wish and copy there both ruby-mode.el and ruby-inf.el (these come with the ruby distribution under the misc directory and can also be downloaded from Ruby's source
Modify your .emacs to tell it where to find your includes and and to use them
; directory to put various el files into
(add-to-list 'load-path "C:/emacs-22.3/includes")
;(1)modify .emacs to use ruby-mode
(autoload 'ruby-mode "ruby-mode"
"Mode for editing ruby source files" t)
(setq auto-mode-alist
(append '(("\\.rb$" . ruby-mode)) auto-mode-alist))
(setq interpreter-mode-alist (append '(("ruby" . ruby-mode))
interpreter-mode-alist))
;(2)set to load inf-ruby and set inf-ruby key definition in ruby-mode.
(autoload 'run-ruby "inf-ruby"
"Run an inferior Ruby process")
(autoload 'inf-ruby-keys "inf-ruby"
"Set local key defs for inf-ruby in ruby-mode")
(add-hook 'ruby-mode-hook
'(lambda ()
(inf-ruby-keys)
))
(optional) I also installed mode-compile.el from http://perso.tls.cena.fr/boubaker/distrib/mode-compile.el and made the corresponding edits in .emacs
; Install mode-compile
(autoload 'mode-compile "mode-compile"
"Compile current buffer based on the major mode" t)
(global-set-key "C-cc" 'mode-compile)
(autoload 'mode-compile-kill "mode-compile"
"Kill compilation launched by `mode-compile'" t)
(global-set-key "C-ck" 'mode-compile-kill)
With those changes Emacs will automatically identify a .rb file as ruby and do syntax highlighting. Then with the chord \C-c\C-s (Control-c, release and then Control-s) irb will start in the box below your file, and you can use all the keys defined by inf-ruby: (\M is the Meta Key which for Windows means Alt)
"\C-c\C-b" 'ruby-send-block
"\C-c\M-b" 'ruby-send-block-and-go
"\C-c\C-x" 'ruby-send-definition
"\C-c\M-x" 'ruby-send-definition-and-go
"\C-c\C-r" 'ruby-send-region
"\C-c\M-r" 'ruby-send-region-and-go
"\C-c\C-z" 'switch-to-ruby
"\C-c\C-l" 'ruby-load-file
"\C-c\C-s" 'run-ruby
If you did the optional step and installed mode-compile, you can also use \C-cc to send the current file to ruby instead of irb
I haven't worked with DrScheme yet, but Netbeans 6.5 includes a full-featured IRB. Have you given it a try?

Where can I find my .emacs file for Emacs running on Windows?

I tried looking for the .emacs file for my Windows installation for Emacs, but I could not find it. Does it have the same filename under Windows as in Unix?
Do I have to create it myself? If so, under what specific directory does it go?
Copy and pasted from the Emacs FAQ, http://www.gnu.org/software/emacs/windows/:
Where do I put my init file?
On Windows, the .emacs file may be called _emacs for backward compatibility with DOS and FAT filesystems where filenames could not start with a dot. Some users prefer to continue using such a name, because Windows Explorer cannot create a file with a name starting with a dot, even though the filesystem and most other programs can handle it. In Emacs 22 and later, the init file may also be called .emacs.d/init.el. Many of the other files that are created by Lisp packages are now stored in the .emacs.d directory too, so this keeps all your Emacs related files in one place.
All the files mentioned above should go in your HOME directory. The HOME directory is determined by following the steps below:
If the environment variable HOME is set, use the directory it indicates.
If the registry entry HKCU\SOFTWARE\GNU\Emacs\HOME is set, use the directory it indicates.
If the registry entry HKLM\SOFTWARE\GNU\Emacs\HOME is set, use the directory it indicates. Not recommended, as it results in users sharing the same HOME directory.
If C:\.emacs exists, then use C:/. This is for backward compatibility, as previous versions defaulted to C:/ if HOME was not set.
Use the user's AppData directory, usually a directory called Application Data under the user's profile directory, the location of which varies according to Windows version and whether the computer is part of a domain.
Within Emacs, ~ at the beginning of a file name is expanded to your HOME directory, so you can always find your .emacs file with C-x C-f ~/.emacs.
There's further information at HOME and Startup Directories on MS-Windows.
It should be stored in the variable user-init-file. Use C-H v user-init-file RET to check. You can also open it directly by using M-x eval-expression RET (find-file user-init-file) RET
Open the file like this in Emacs for Windows:
C-x C-f ~/.emacs
More information in the Emacs Wiki
On my Vista box it's in C:\Users\<USER>\AppData\Roaming\
Note that it may NOT be enough to just type Ctrl-x Ctrl-f ~/.emacs and create the file.
It may be that your Emacs application uses a different place to store your init file, and if so, then creating the file ~/.emacs simply creates a useless file which your Emacs application ignores.
Also, you may want to do more than just access the .emacs init file, but you may want to know where it is, i.e., its pathname.
To get at this there are two methods:
Easy way: type Ctrl + H V user-init-file Return
Slightly trickier way:
You can find out where your system is storing its own .emacs file by:
Click options and scroll down to "Set Default Font..."
Change the font setting and click okay
On the options menu, go down to "Save Options"
When the options are saved, the system saves its .emacs file,
and you can read the file path in the minibuffer at the bottom of the Emacs screen
In Windows 7 put your init.el file in C:\Users\user-name\AppData\Roaming\.emacs.d\, where user-name is your user/login folder.
Take care so your init.el file won't be named init.el.txt. This is something Windows does if you create your file with some editor like Notepad.
On versions of Emacs on Windows above 22, it seems to have moved to
~/.emacs.d/init.el
, ~ being the value of your environment variable HOME (see Control Panel → System → Advanced → Environment variables).
The file itself might not exist. In that case just create it.
You must create an emacs initialization file. One is not automatically created.
I had a similar issue and this answer tracks down what I did.
My issue was my ~/.emacs.el file was not loading. Strange because this has always worked for me.
This question/answer helped me but I had to put my init file in the %USERPROFILE%\AppData\Roaming\.emacs.d\init.el because this is apparently the default behavior on Windows.
To troubleshoot this, I ran the following in the emacs *scratch* buffer.
user-emacs-directory
"~/.emacs.d/"
When I saw user-emacs-directory was ~/.emacs.d, I simply moved my .emacs.el file to %USERPROFILE%\.emacs.d\init.el. But this still didn't work.
I continued with expand-file-name as shown below:
(expand-file-name user-emacs-directory)
"c:/Users/pats/AppData/Roaming/.emacs.d/"
Got to love how Windows works. (not) So I moved my emacs.el file to the %USERPROFILE%\AppData\Roaming\.emacs.d\init.el and this worked. The file was now being read. But I got other errors because my initialization file loaded other (personal emacs) files (in ~/myenv/emacs/*.el.
Warning (initialization): An error occurred while loading ‘c:/Users/pats/AppData/Roaming/.emacs.d/init.el’:
Hum... Seems like all my files ~/myenv/emacs/*.el would need to be moved in order for this to work but I didn't want to do that. Then I realized that because the HOME environment variable was not set, emacs was performing its default behavior.
SOLUTION
Once I set my windows HOME environment variable to %USERPROFILE% everything began to work like it has for the past 25 years. :-)
To set the HOME environment variable, I typed WindowsKey+"edit environment variables for your account" to open the Environment Variables dialog box, and entered HOME=%USERPROFILE%.
Now my emacs initialization file .emacs.el is is back to its rightful place $HOME/.emacs.el and not in %USERPROFILE%\AppData\Roaming\.emacs.d\init.el
To be fair, if Windows had just one place to put files for user installed packages the solution of making HOME=%USERPROFILE\AppData\Roaming might be acceptable, but because some applications use %USERPROFILE%, some use %USERPROFILE\AppData\Roaming and others use %USERPROFILE\AppData\Local it just makes it difficult to know where to find your configuration files.
I prefer having everything in my %USERPROFILE% or $HOME directory.
Another similar question was here:
Emacs init.el file doesn't load
As kanja answered, the path to this file is stored in the user-init-file variable (or if no init file exists, the variable contains the default value for where to create it).
So regardless of which of the possible init file names you are using, and which directory it is in, you should be able to visit your init file with:
M-: (find-file user-init-file) RET
Or display its full path in the echo area with:
M-: (expand-file-name user-init-file) RET
On Emacs 23 and Windows 7 it only works if you set:
HKCU\SOFTWARE\GNU\Emacs\HOME
After Emacs 27.1, emacs has started respecting the $XDG_CONFIG_HOME. The init file or the init directory can now be found in $XDG_CONFIG_HOME/emacs/init.el.
In Windows $XDG_CONFIG_HOME could translate to %LOCALAPPDATA%.
In any case you can use the following emacs variables to find out the location of the your initialization file by M-x eval-expression
user-init-file
or the emacs configuration directory
user-emacs-directory
I've found that Emacs 22 will occasionally open either "C:\Documents and Settings\username\Application Data\.emacs", or just "C:\Documents and Settings\username\.emacs" on my XP machine. I haven't found an explanation for why it occasionally changes it's mind.
~ will always point to whatever the current instance of emacs thinks is HOME, but kanja's tip (C-h v user-init-file) will always tell you what ~/.emacs actually maps to.
On Windows 8.1, if Emacs is started from Windows Explorer, a shortcut or from cmd console it uses C:\Users\<USER>\AppData\Roaming.emacs init file. When I start Emacs from PowerShell, Emacs looks for its init file in C:\Users\<USER> folder. The fix to this issue was to set the HOME user environment variable (Control Panel\System and Security\System->Advanced system settings->Advanced->Environment variables) to C:\Users\<USER>. After this change, no matter how I start Emacs, it uses the same init file (see the accepted answer of this question)
On Windows XP it's:
C:\Documents and Settings\yourusernamehere\Application Data\
There is a list of directories based on your Windows version and extra information:
http://www.gnu.org/software/emacs/manual/html_node/emacs/Windows-HOME.html
For WIndows7& Emacs26.3:
if HOME environment is set, then the .emacs file should be in that folder.
otherwise, it should be in c:\.
In both cases, if .emacs is not there, _emacs should be used.
This is because we cannot create .emacs file according to the windows file naming rules.(but we can download or copy it from somewhere else).

Resources