Emacs can't find plink - emacs

I am running emacs 24 and I want to set up tramp to read/write file on my ubuntu machine.
I read emacs 24 on windows 7, tramp cannot find plink program. And i did print the exec path, I do have C:/Programs/Putty in my exec path:
exec-path is a variable defined in `C source code'.
Its value is
("C:/Programs/PuTTy" .....)
But I still get
plink -load 10.136.11.77 -t env 'TERM=dumb' 'PROMPT_COMMAND=' 'PS1=#$ ' /bin/sh && exit || exit
plink is not recognized as an internal or external command, operable program or batch file.
I have this in my .emacs:
(require 'tramp)
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
(add-to-list 'exec-path "C:/Programs/PuTTy")
(if (eq system-type 'windows-nt)
(setq tramp-default-method "plinkx"))
any idea how to fix my problem?

Related

/Applications/Clozure CL.app/Contents/Resources/ccl/dx86cl64.image: cannot execute binary file

Setup:
MacOS 10.12.4
Clozure CL Version 1.11.1 (16714)
Emacs Version 25.1 (9.0)
Problem:
Clozure CL app starts, REPL runs.
Emacs inferior-list function terminates with:
(progn (load "/Users/Szabolcs/.emacs.d/elpa/slime-20170319.1601/swank-loader.lisp" :verbose t) (funcall (read-from-string "swank-loader:init")) (funcall (read-from-string "swank:start-server") "/var/folders/v7/st79grks643g7c3q_dhhb88r0000gn/T/slime.49146"))
/usr/local/bin/ccl64: line 81: /Applications/Clozure CL.app/Contents/Resources/ccl/dx86cl64.image: cannot execute binary file
/usr/local/bin/ccl64: line 81: /Applications/Clozure CL.app/Contents/Resources/ccl/dx86cl64.image: Undefined error: 0
Process inferior-lisp exited abnormally with code 1
init.el
(require 'slime)
(setq inferior-lisp-program "/usr/local/bin/ccl64 -K utf-8")
(require 'slime)
(setq slime-net-coding-system 'utf-8-unix)
(slime-setup '(slime-fancy))
;; (prefer-coding-system 'utf-8)
;; (set-terminal-coding-system 'utf-8)
(slime)
(add-hook 'slime-mode-hook #'paredit-mode)
I tried to modify owner and group, if maybe that causes it not to run. But didn't work out.
From the home-site of clozure CL. They recomment to set the inferior-lisp-program to lx86cl64 binary it should be
(setq inferior-lisp-program "/path/to/ccl/lx86cl64")
But Nowadays I use roswell for installing and using Lisp I use roswell (is like rvm for lisp), it has a complet an easy setup, and then you can use it with the majority of lisp distributions

Ipython in emacs dumps trash text into shell

When I launch an ipython process in an emacs buffer, it prints trash text to the buffer:
^[[J^[[?7h^[[?12l^[[?25h^[[?2004l
^[[?12l^[[?25h
The ipython buffer does this every time I launch it, every time I evaluate code in another buffer, every time I evaluate code in that buffer. Ipython never does this from the bash CLI, In [1]:
Where could I look to change this behavior to a more sensible and terse prompt, such as what ipython does in bash?
This is in emacs 24.5.1 inside tmux 2.0 with python 2.7.6, ipython 5.1.0, python-mode version 6.2.1, running on Ubuntu 14.04 LTS.
Here's every line in my .emacs file that even mentions python:
; (require 'python-settings)
; (require 'ein)
(setq py-install-directory "~/.emacs.d/python-mode")
(add-to-list 'load-path py-install-directory)
(require 'python-mode)
(setq python-shell-interpreter "~/anaconda2/bin/python"
python-shell-interpreter-args "-i console --matplotlib")
(setq-default py-shell-name "ipython")
(setq-default py-which-bufname "IPython")
; use the wx backend, for both mayavi and matplotlib
(setq py-python-command-args
'("--gui=wx" "--pylab=wx" "-colors" "Linux"))
;; responsible for the annoying window rearrangement behavior after every code execution? Nope.
(setq py-force-py-shell-name-p t)
; switch to the interpreter after executing code
(setq py-shell-switch-buffers-on-execute-p nil)
(setq py-switch-buffers-on-execute-p nil)
(setq py-shell-local-path "/home/ftamborello/anaconda2/bin/python"
py-use-local-default t)
; don't split windows
(setq py-split-window-on-execute-p nil)
; try to automagically figure out indentation
(setq py-smart-indentation t)
; enable flycheck syntax support
; (add-hook 'after-init-hook #'global-flycheck-mode)
what Thomas K suggests is the actual solution, just edit your init.el file and paste the following:
RUN IPYTHON6.4 IN EMACS ALONG WITH PYTHON3+
(setq python-shell-interpreter "ipython3"
python-shell-interpreter-args "-i --simple-prompt")

Emacs: Cannot open load file, go-autocomplete

I'm trying to install [gocode][1] on Emacs currently and am receiving the current error message:
Warning (initialization): An error occurred while loading `/home/darwin/.emacs':
File error: Cannot open load file, no such file or directory, go-autocomplete
To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file. Start Emacs with
the `--debug-init' option to view a complete error backtrace.
And when I run Emacs with --debug-init, I receive this (it's not too pretty):
Debugger entered--Lisp error: (file-error "Cannot open load file" "no such file or directory" "go-autocomplete")
require(go-autocomplete)
eval-buffer(#<buffer *load*> nil "/home/darwin/.emacs" nil t) ; Reading at buffer position 1831
load-with-code-conversion("/home/darwin/.emacs" "/home/darwin/.emacs" t t)
load("~/.emacs" t t)
#[0 "\205\262� \306=\203�\307\310Q\202;� \311=\204�\307\312Q\202;�\313\307\314\315#\203*�\316\202;�\313\307\314\317#\203:�\320\nB\321\202;�\316\322\323\322\211#\210\322=\203a�\324\325\326\307\327Q!\"\323\322\211#\210\322=\203`�\210\203\243�\330!\331\232\203\243�\332!\211\333P\334!\203}�\211\202\210�\334!\203\207�\202\210�\314\262\203\241�\335\"\203\237�\336\337#\210\340\341!\210\266\f?\205\260�\314\323\342\322\211#)\262\207" [init-file-user system-type delayed-warnings-list user-init-file inhibit-default-init inhibit-startup-screen ms-dos "~" "/_emacs" windows-nt "/.emacs" directory-files nil "^\\.emacs\\(\\.elc?\\)?$" "~/.emacs" "^_emacs\\(\\.elc?\\)?$" (initialization "`_emacs' init file is deprecated, please use `.emacs'") "~/_emacs" t load expand-file-name "init" file-name-as-directory "/.emacs.d" file-name-extension "elc" file-name-sans-extension ".el" file-exists-p file-newer-than-file-p message "Warning: %s is newer than %s" sit-for 1 "default"] 7 "\n\n(fn)"]()
command-line()
normal-top-level()
I've installed the Emacs (regular) autocomplete version required for gocode using the package manager (gocode isn't available on this manager by the way).
My directories if they help:
Emacs folder is called: .emacs.d:
/.emacs.d
/auto-save-list
/elpa
go-autocomplete.el
Emacs init folder:
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(custom-enabled-themes (quote (misterioso)))
'(inhibit-startup-screen t))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
(when (>= emacs-major-version 24)
(require 'package)
(package-initialize)
; (add-to-list 'package-archives
; '("melpa-stable" . "http://stable.melpa.org/packages/") t)
(add-to-list 'package-archives '("marmalade" . "https://marmalade-repo.org/packages/"))
(add-to-list 'package-archives '("melpa-stable" . "http://stable.melpa.org/packages/") t)
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)
)
;; Update Emacs config for godoc
(setenv "PATH" "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/local/go/bin")
(setenv "GOPATH" "~/go")
;; calls gofmt before save
(setq exec-path (cons "/usr/local/go/bin" exec-path))
(add-to-list 'exec-path "/go/bin")
;(add-hook 'before-save-hook 'gofmt-before-save)
(defun my-go-mode-hook ()
; Call Gofmt before saving
(add-hook 'before-save-hook 'gofmt-before-save)
; Customize compile command to run go build
(if (not (string-match "go" compile-command))
(set (make-local-variable 'compile-command)
"go build -v && go test -v && go vet"))
; Godef jump key binding
(local-set-key (kbd "M-.") 'godef-jump))
(add-hook 'go-mode-hook 'my-go-mode-hook)
;; Gocode: Go aware Autocomplete
(require 'go-autocomplete)
(require 'auto-complete-config)
;; Go eldoc (via package control) REQUIRES GOCODE
(require 'go-eldoc)
(add-hook 'go-mode-hook 'go-eldoc-setup)
If anyone could help me figure out how I can get gocode to work that would be fantastic. Thank you in advance.
P.S. I can add other directories if needed.
[1]: https://github.com/nsf/gocode
The root directory of .emacs.d is not generally a part of the load-path, and recent versions of Emacs will even give the user a warning message discouraging against doing it if in fact a user did it. Create a sub-folder called lisp or hello-world and put your library inside it and then add the lisp or hello-world directory to your load-path and restart Emacs. Here is a link to the related documentation for load-path:  https://www.gnu.org/software/emacs/manual/html_node/emacs/Lisp-Libraries.html
Example (place inside .emacs file):
(add-to-list 'load-path "/path/to/my/lisp/library")

Update multi-term buffer name based on PWD

If I use konsole or other terminal, the terminal tag name can change based on PWD. But in multi-term, the buffer name is *terminal<number>*. This is not very nice. Because when I switch between them, the name is not very informative. So I want to rename it based on PWD.
I find that the Enter key is bind to term-send-raw, so I write a function
(defadvice term-send-raw (around rename-term-name activate)
(progn
(rename-buffer
(concat "⇒ "
(shell-command-to-string "pwd | xargs basename | tr -d '\n'")
(format-time-string " [%M ∞ %S]")))
ad-do-it))
But the problem is pwd command return the PWD of the terminal buffer, while it is not the PWD of the SHELL in that terminal.
The PWD of the terminal buffer is set by defcustom multi-term-default-dir. And it does not change when the PWD change in the SHELL.
(defcustom multi-term-default-dir "~/"
"The default directory for terms if current directory doesn't exist."
:type 'string
:group 'multi-term)
How can I get the PWD of the SHELL in the terminal?
Regards.
AFAIK there is no easy way to retrieve information from a running process.
But if you want to get the current directory you could:
ask the shell to print it
parse and trace the command-line for functions like cd, pushd, popd…
poll /proc/PID/cwd
The first method is described in the header of term.el (M-xfind-libraryRETtermRET).
And now, thank you for your question, you gave me the opportunity to do this:
(defadvice term-send-input (after update-current-directory)
(let* ((pid (process-id (get-buffer-process (current-buffer))))
(cwd (file-truename (format "/proc/%d/cwd" pid))))
(cd cwd)))
(ad-activate 'term-send-input)
It's a naive implementation of the third method and it doesn't work if the user uses su or ssh. However, I don't know if it's possible withouth using the first or the second method.
In your case, you can just replace the cd command with whatever you want.
Building off of Daimrod's answer for polling /proc/PID/cwd, I found a way get around the problem that Reed pointed out where the advice doesn't pick up the updated CWD immediately and you have to hit Enter twice.
If you move the CWD update code to its own function and use run-at-time to call it from the advice at a later time, it will pick up the updated CWD correctly. Unfortunately I don't know enough about Emacs' scheduling to explain why this works (any enlightenment would be appreciated).
Here's my code based on Daimrod's. Note I advised term-send-input for line-mode and term-send-return for char-mode. I tested this using multi-term on Emacs 24.3.1:
(defadvice term-send-input (after update-current-directory)
(run-at-time "0.1 sec" nil 'term-update-dir)
)
(ad-activate 'term-send-input)
(defadvice term-send-return (after update-current-directory)
(run-at-time "0.1 sec" nil 'term-update-dir)
)
(ad-activate 'term-send-return)
(defun term-update-dir ()
(let* ((pid (process-id (get-buffer-process (current-buffer))))
(cwd (file-truename (format "/proc/%d/cwd" pid))))
(unless (equal (file-name-as-directory cwd) default-directory)
(message (concat "Switching dir to " cwd))
(cd cwd)))
)
Most terminals get their window name from the command echo -en. In zsh you can put this in your ~/.zshenv
precmd() { echo -en "\e]0;`basename ${PWD}`\a" }
and that will get the basename of your PWD environment variable. Ideally multi-term would do something similar and put it in multi-term-buffer-name, which is the variable which holds its buffer name.
Yes, this is not a complete solution. I'm hoping for one too!
Try this:
(defun open-or-jump-to-multi-term ()
(interactive)
(if (string-prefix-p "*terminal<" (buffer-name))
(delete-window)
(progn
(setq bufname (concat "*terminal<" (directory-file-name (file-name-directory (buffer-file-name))) ">"))
(if (get-buffer-process bufname)
(switch-to-buffer-other-window bufname)
(progn
(split-window-right)
(other-window 1)
(multi-term)
(rename-buffer bufname)
)
)))
)
(global-set-key (kbd "C-`") 'open-or-jump-to-multi-term)

change .emacs file's location

I am working on windows xp
I stored emacs in usb
I want to carry the .emacs file as well as binary files
what I tried are
(setenv “HOME” (format "%s" (getenv "emacspath")))
(setenv “HOME” (format "%s/" (getenv "emacspath")))
It seems works if I eval-expression in emacs
After setenv, I could notice setting env is works well by (getenv "home")
but I put the (setenv "home" (format "%s/" (getenv "emacspath")))
in "site-start.el" file in "site-lisp" folder, starting emacs says "Symbol's value as variable is void: "HOME"
Any ideas?
An easier way - just create a batch file on your USB drive where you can set all env variables you need. Then start emacs.exe from the batch.
For example if you want to run SBCL add the following lines to your batch
rem SBCL_HOME is required for SBCL
set SBCL_HOME=%utils%\Lisp\sbcl\1.0.29
set SBCL_RUN=%SBCL_HOME%\sbcl.exe
set SBCL_OPTIONS=--noinform
How about using default.el either as a symlink or as a simple elisp pinter to your file:
(load-file "/path/to/usb/.emacs")
Add following code to a file (e.g. c:/.emacs).
;; This function must be at begin
(defun zxy-relocate-dotemacs ()
"Relocate .emacs file"
(interactive)
(with-temp-buffer
(let (print-level print-length)
(insert (format "(load-file \"%s\")" load-file-name))
(if (file-exists-p "~/.emacs")
(message "[zxy] Don't need relocate .emacs file!")
(progn
(message "[zxy] Relocate .emacs file.")
(write-file "~/.emacs"))))))
(zxy-relocate-dotemacs)
;; Your configuration here
Open emacs and M-x load-file c:/.emacs.
Then it will relocate .emacs to c:/.emacs.
I use this when I copy my emacs to a new computer.
More information please visit my blog abuot emacs.
http://coordinate.sinaapp.com/?cat=3