Emacs auto-complete via ELPA - emacs24

I've just installed via elpa auto-complete 1.4 and I can see the directory in my .emacs.d/elpa/ folder. Now what do I do? I've tried various .emacs lines, but I'm never sure what an elpa install really does and what I would still need to do to my .emacs file. AFA Emacs is concerned, it can't find auto-complete. I saw this on another install:
(add-to-list 'load-path "~/.emacs.d")
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "/home/memyselfi/.emacs.d/ac-dict")
(ac-config-default)
(add-to-list 'ac-modes 'lisp-mode)
(require 'auto-complete)
. . . but this doesn't work. Actually, I'd like auto-complete to do the advance guess/autocomplete in the minibuffer, as when it suggests files, commands, etc.

auto-complete does not do fuzzy matching in the minibuffer.
You probably want to enable ido-mode.
Try putting this in your init.el
(ido-mode t) ;; auto-completes file-names etc
(setq ido-enable-flex-matching t) ;; enables fuzzy matching
There are other packages that do this, but ido-mode comes standard with Emacs, so is probably easiest to get going.

Related

Emacs haskell-mode: "Searching for program: no such file or directory, ghci"

For some reason emacs is not able to find my ghci. I am running Ubuntu 16.04, and followed the instructions in this tutorial to the book.
Using which ghci I get the path /opt/ghc/7.10.3/bin/ghci. And executing M-: exec-path and M-: (getenv "PATH") I can see that path correctly printed.
I have tried to explicitly set the PATH variable in emacs like this, which changes nothing since as far as I could tell it was already there. From this answer.
(setenv "PATH" "/usr/local/bin:/usr/bin:/bin:/opt/cabal/1.22/bin/cabal:/opt/ghc/7.10.3/bin/ghci")
(setq exec-path (split-string (getenv "PATH") path-separator)
The same thing happens when I use
(custom-set-variables '(haskell-process-type 'cabal-repl)) namely the error: "Searching for program: no such file or directory, cabal"
I would greatly appreciate help. :) I have no idea what to do, and I haven't found any answers on the internet.
The issue was that I was adding the path to the actual executable, rather than the folder in which the executable sits.
So:
/opt/cabal/1.22/bin/cabal
should be
/opt/cabal/1.22/bin/
and:
/opt/ghc/7.10.3/bin/ghci
should be
/opt/ghc/7.10.3/bin/

Clang_complete not worrking

unfortunately I can't manage to make clang_complete work and I could need your help.
I've already compiled vim 7.4 with python support. Here is the output of vim --version | grep python:
+cryptv +linebreak +python/dyn +viminfo
-cscope +lispindent +python3/dyn +vreplace
I followed this guide: https://vtluug.org/wiki/Clang_Complete
Please note that I've started from a clean installation (i.e. no other plugins and no further entries in my .vimrc (except for those shown in the guide above)).
According to the tutorials I've seen so far everything should be working.
However, if I try to get code completion for the following example nothing happens. If I press <c-x><x-u> I receive the error "completefunc not set".
#include <string>
int main()
{
std::string s;
s.
}
Moreover, I've installed the newest version of clang from source and it in my $PATH.
Is there a way to verify that clang_complete is actually installed?
What might cause this problem?
Any help is much appreciated.
Add
filetype plugin indent on
to your vimrc, its missing from the vimrc snippet in the link. This tells vim to do filetype detection and fire autocommands related to those file types. Without it you won't run the following autocommands.
au FileType c,cpp,objc,objcpp call <SID>ClangCompleteInit()
au FileType c.*,cpp.*,objc.*,objcpp.* call <SID>ClangCompleteInit()
Which probably initalize ClangComplete.

Racket: How to retrieve the path of the running file?

I need a way to get the path of the running script (the directory that contains the source file), but
(current-directory)
never points there (in this case an external drive), but rather to some predefined location.
I created a file to try all the 'find-system-path's, but none of them are the running file! The Racket docs are not helping.
#lang web-server/insta
(define (start request)
(local [{define (build-ul items)
`(ul ,#(map itemize items))}
{define (itemize item)
`(li ,(some-system-path->string (find-system-path item)))}]
(response/xexpr
`(html
(head (title "Directories"))
(body (h1 ,"Some Paths")
(p ,(build-ul special-paths)))))))
(define special-paths (list 'home-dir
'pref-dir
'pref-file
'temp-dir
'init-dir
'init-file
;'links-file ; not available for Linux
'addon-dir
'doc-dir
'desk-dir
'sys-dir
'exec-file
'run-file
'collects-dir
'orig-dir))
The purpose is for a local web-server application (music server) that will modify sub-directories under the directory that contains the source file. I will be carrying the app on a USB stick, so it needs to be able to locate its own directory as I carry it between machines and operating systems with Racket installed.
Easy way: take the running script name, make it into a complete path,then take its directory:
(path-only (path->complete-path (find-system-path 'run-file)))
But you're more likely interested not in the file that was used to execute things (the web server), but in the actual source file that you're putting your code in. Ie, you want some resources to be close to your source. An older way of doing this is:
(require mzlib/etc)
(this-expression-source-directory)
A better way of doing this is to use `runtime-path', which is a way to define such resources:
(require racket/runtime-path)
(define-runtime-path my-picture "pic.png")
This is better since it also registers the path as something that your script depends on -- so if you were to package your code as an installer, for example, Racket would know to package up that png file too.
And finally, you can use it to point at a whole directory:
(define-runtime-path HERE ".")
... (build-path HERE "pic.png") ...
If you want the absolute path, then I think this should do it:
(build-path (find-system-path 'orig-dir)
(find-system-path 'run-file))

Having eruby-nxhtml-mumamo-mode be set every time I open a .html.erb file

I downloaded nxhtml and unzip it. I then put this in my .emacs file.
(add-to-list 'load-path "~/nxhtml/util")
(require 'mumamo-fun)
(setq mumamo-chunk-coloring 'submode-colored)
(add-to-list 'auto-mode-alist '("\\.rhtml\\'" . eruby-nxhtml-mumamo-mode))
(add-to-list 'auto-mode-alist '("\\.html\\.erb\\'" . eruby-nxhtml-mumamo-mode))
When I open an .html.erb file it does not have the proper mode set(and therefore improper syntax highlighting). I know the require statement is running correctly b/c I can manually set aquamacs to eruby-nxhtml-mumamo-mode and if I comment out the require line I can't even switch to that mode. I have even tried replacing the eruby...-mode with other modes like c++-mode and other modes I know work and that doesn't work either.
So is my problem with the regex? I am not sure. Any help would be appreciated.
Try the following:
(add-to-list 'auto-mode-alist '("\\.rhtml?$" . eruby-nxhtml-mumamo-mode))
(add-to-list 'auto-mode-alist '("\\.html?\\.erb$" . eruby-nxhtml-mumamo-mode))
It appears you had an escaped comma at the end of your expressions.
I don't know if the lack of the 'l' in your header was intentional or not, but the question mark should account for it either way. The dollar sign anchors the expression to the end of the string, and are nominally optional, but it's nice to be explicit.

What do I need to put in .emacs to print to default Windows printer?

I used to have postcript printing working perfectly in Emacs 21 in Windows+Cygwin, but after upgrading to Emacs 23, I am receiving the following error in the minibuffer:
Opening output file: invalid argument, C:/PDFCreator:
My current .emacs contain the current relevant statements:
(require 'ps-print)
(setq ps-spool-duplex t)
(setq ps-auto-font-detect nil)
(setq ps-print-color-p nil)
It used to have the following line as well:
(setq ps-lpr-command "qprt")
But it generates a similar error:
Searching for program: no such file or directory, qprt
Any idea what changed in Emacs 23 and how I can bring printing back to life?
(at this point I am only interested in printing to the default Windows printer, which is PDFCreator).
From the Emacs Wiki PrintingFromEmacs, the following configuration is recommended.
Where lpr is the Cygwin lpr version.
(setenv "PRINTER" "PDFCreator")
(cond ((eq system-type 'windows-nt)
(setq ps-printer-name "PDFCreator")
(setq ps-printer-name-option "-d")
(setq ps-lpr-command "/bin/lpr")))
You could also use the Ghostscript configuration there and select the PDFCreator printer from the popup. Adjusting your GS_LIB and your ghostscript binary location accordingly.
(setenv "GS_LIB" "e:/tools/GSTools/gs8.14/gs8.14/lib;e:/tools/GSTools/gs8.14/fonts")
(setq ps-lpr-command "e:/tools/GSTools/gs8.14/gs8.14/bin/gswin32c.exe")
(setq ps-lpr-switches '("-q" "-dNOPAUSE" "-dBATCH" "-sDEVICE=mswinpr2"))
(setq ps-printer-name t)
Note to users of PDFCreator - they now install a bunch of toolbars and take over your web browsers when you install it.
http://en.wikipedia.org/wiki/Pdfcreator#Adware_toolbar_controversy
I had PDFCreator working fine with Emacs, then I made the mistake of letting PDFCreator update itself. It redirected all my search queries to Bing, took over a bunch of browser settings, added toolbars, default landing pages etc. It took me about an hour to clean out all the junk it added.
I had the same symtom as the poster, but it wasn't because of any change in Emacs 23.
My printer is a postscript capable network printer.
First, my hostname had changed sligtly when my work computer was upgraded from Windows to Vista. I had to change one character accordingly:
From
(setq ps-printer-name "//evf4ce46ac4ad3/seki81050470cm")
to
(setq ps-printer-name "//e7f4ce46ac4ad3/seki81050470cm")
This changed the error message from
direct-print-region-helper: Opening output file: invalid argument, //evf4ce46ac4ad3/seki81050470cm
to
direct-print-region-helper: Opening output file: no such file or directory, //e7f4ce46ac4ad3/seki81050470cm
Then I had to enable sharing of the printer. This is found in
\\e7f4ce46ac4ad3\Printers
which probably can be found in a more generic way. \\%computername%\Printers didn't work for me; I don't know why.
Right-click on the printer icon, select Sharing and enable Share this printer, with a suitable printer name, preferably with no spaces in it.
This was enough to enable printing for me.

Resources