How to change GUD breakpoint keybinding to the old one - emacs

Currently, I am using GUD in the newest version of Emacs. The keybinding has changed since the old Emacs. Now it is "\C-x \C-a \C-b" for setting a breakpoint but it was \C-[space].
I was wondering if there is anyway to change the keybinding to the old format? (For some reason I cannot change my Emacs version)
I am using Emacs 24.5
Here is my .emacs file:
;; .emacs
;;; uncomment this line to disable loading of "default.el" at startup
;; (setq inhibit-default-init t)
;; turn on font-lock mode
(when (fboundp 'global-font-lock-mode)
(global-font-lock-mode t))
;; enable visual feedback on selections
;(setq transient-mark-mode t)
;; default to better frame titles
(setq frame-title-format
(concat "%b - emacs#" (system-name)))
;; default to unified diffs
(setq diff-switches "-u")
;; always end a file with a newline
;(setq require-final-newline 'query)
;; Show main source buffer when using gdb
(setq gdb-show-main t)
;; Show all debugging frames in GDB
(setq gdb-many-windows t)
;; see buffer list on the same frame
(global-set-key "\C-x\C-b" 'buffer-menu)
;; old keybinding for breakoint in GUD
(require 'gud)
(define-key gud-mode-map "\C-x SPC" 'gud-break)

Changing your Emacs version should not be necessary. Try this:
(require 'gud)
(define-key gud-mode-map (kbd "C-SPC") 'gud-break)
This will allow you to trigger gud-break with C-SPC. If you are not talking about the gud-break command, replace it with the command you are referring too.
Generally, the answer to the question "can I change this keybinding?" is always "yes" in Emacs.

Somehow I was able to fix it with this:
(require 'gud)
(global-set-key [24 32] (quote gud-break))

Related

Conflicts between org-mode and yasnippet

EDIT My issue was related to snippet syntax all along... The configuration below totally works.
I'm trying to use org-mode and yasnippet together and it's not working even with some of the workarounds on the org-mode FAQ. Whenever I hit TAB on a snippet abbreviation the word gets deleted. TAB behaves normally if I'm not over a snippet word, so there's something going on...
I'm using Org-mode version 7.7, yasnippet (version 0.7.0), and GNU Emacs 23.4.1.
Here's my setup:
(setq load-path
(append (list nil
"~/.emacs.d/site-lisp/yasnippet"
"~/.emacs.d/site-lisp/org-7.7/lisp")
load-path))
;; set up yasnippet
(require 'yasnippet)
(yas/initialize)
(setq yas/snippet-dirs '("~/.emacs.d/mysnippets"
"~/.emacs.d/site-lisp/yasnippet/snippets"))
(mapc 'yas/load-directory yas/snippet-dirs)
;; set up org mode
(require 'org-install)
;; fix some org-mode + yasnippet conflicts:
(defun yas/org-very-safe-expand ()
(let ((yas/fallback-behavior 'return-nil)) (yas/expand)))
(add-hook 'org-mode-hook
(lambda ()
(make-variable-buffer-local 'yas/trigger-key)
(setq yas/trigger-key [tab])
(add-to-list 'org-tab-first-hook 'yas/org-very-safe-expand)
(define-key yas/keymap [tab] 'yas/next-field)))
And I'm pretty sure the hook is running as expected because of the following output of C-h v org-tab-first-hook in an org buffer:
org-tab-first-hook is a variable defined in `org.el'.
Its value is
(yas/org-very-safe-expand org-hide-block-toggle-maybe org-src-native-tab-command-maybe org-babel-hide-result-toggle-maybe)
And here's C-h k TAB in an org buffer:
<tab> runs the command org-cycle, which is an interactive Lisp
function in `org.el'.
EDIT
After doing a edebug-defun on my yas/org-very-safe-expand function I'm seeing the following message
Result: "[yas] elisp error! Symbol's value as variable is void: err"
So yas is error'ing out somewhere... My edebug foo is not quite up to par but if I get some time I'll try to single step through and see where the error is. My full emacs configuration is on github here.
Turns out my issue was related to snippet syntax, not setup. Silly silly me...
In other words, this totally works:
;; fix some org-mode + yasnippet conflicts:
(defun yas/org-very-safe-expand ()
(let ((yas/fallback-behavior 'return-nil)) (yas/expand)))
(add-hook 'org-mode-hook
(lambda ()
(make-variable-buffer-local 'yas/trigger-key)
(setq yas/trigger-key [tab])
(add-to-list 'org-tab-first-hook 'yas/org-very-safe-expand)
(define-key yas/keymap [tab] 'yas/next-field)))
This took me some time to get worked out as well. I'm using Org-mode version 7.7, yasnippet (version 0.6.1c), GNU Emacs 22.1.1. Here are the relevant portions of my .emacs file (there is some flyspell stuff that is irrelevant):
;;
;; org-mode stuff
;;
(add-to-list 'load-path "/Users/cmalone/install/org-mode/org-mode/lisp")
(add-to-list 'load-path "/Users/cmalone/install/org-mode/org-mode/contrib/lisp")
(require 'org-install)
;;
;; for YASnippet
;;
(add-to-list 'load-path "/Users/cmalone/.emacs.d/plugins/yasnippet-0.6.1c")
(require 'yasnippet)
(yas/initialize)
(yas/load-directory "/Users/cmalone/.emacs.d/plugins/yasnippet-0.6.1c/snippets")
;; Make TAB the yas trigger key in the org-mode-hook and enable flyspell mode and autofill
(add-hook 'org-mode-hook
(lambda ()
;; yasnippet
(make-variable-buffer-local 'yas/trigger-key)
(org-set-local 'yas/trigger-key [tab])
(define-key yas/keymap [tab] 'yas/next-field-group)
;; flyspell mode for spell checking everywhere
;; (flyspell-mode 1)
;; auto-fill mode on
(auto-fill-mode 1)))
C-h v org-tab-first-hook is the same as yours except of the yas/org-very-safe-expand of course. C-h k TAB shows:
TAB runs the command yas/expand
which is an interactive Lisp function in `yasnippet.el'.
It is bound to TAB, <menu-bar> <YASnippet> <Expand trigger>.
(yas/expand)
Expand a snippet before point.
If no snippet expansion is possible, fall back to the behaviour
defined in `yas/fallback-behavior'

emacs auto-fill-mode doesn't initialise

I want to enable line-wrapping without having to type 'M-x auto-fill-mode' everytime I start emacs. I've tried putting (setq auto-fill-mode 1) and (auto-fill-mode 1) in the .emacs file, but neither work. Why is this, and how do I fix it?
Thanks
It is a minor-mode so you need to enable it for the modes where you want it used. So, for example, if you want auto-fill-mode enabled in text mode, you need to add the following to your .emacs file:
(add-hook 'text-mode-hook '(lambda ()
(auto-fill-mode 1)))
auto-fill-mode is a minor mode so (setq auto-fill-mode 1) wont start it.
You can add a hook to start auto-fill-mode with the text-mode (with which it is normally used) or any other mode you normally use it with, by doing
(add-hook 'text-mode-hook 'turn-on-auto-fill)
Alternatively, if you want the auto-fill-mode on for all the files you edit. You can start it when any type of file is opened with:
(setq auto-mode-alist (cons '("*" . auto-fill-mode) auto-mode-alist))
But having it always on is irritating at times, so its better to bind the starting of the mode to a familiar key sequence
(global-set-key (kbd "C-c q") 'auto-fill-mode)

Naive question on how to type-annotated my ocaml prog. in emacs

I heard we can annotate ocaml prog. by their types. An older thread in the forum suggested using ocaml mode of
http://cristal.inria.fr/~remy/poly/emacs/index.html
I have been using Tuareg mode, in which it suggested using "c-c c-t" to retrieve types, cf. this piece of codes in tuareg.el
(when tuareg-with-caml-mode-p
;; Trigger caml-types
(define-key map [?\C-c ?\C-t] 'caml-types-show-type)
;; To prevent misbehavior in case of error during exploration.
(define-key map [(control mouse-2)] 'caml-types-mouse-ignore)
(define-key map [(control down-mouse-2)] 'caml-types-explore)
I got "c-c c-t" undefined although everything seems to be well configured.
Here is the .emacs file
(setq auto-mode-alist
(cons '("\\.ml[iyl]?$" . caml-mode) auto-mode-alist))
(autoload 'caml-mode "ocaml"
"Major mode for editing Caml code." t)
(autoload 'camldebug "camldebug"
"Call the camldebugger on FILE" t)
;; adjust paths for emacs source code
(add-to-list 'load-path "~/my-emacs-config/caml-mode")
;; adjust paths for emacs ocaml info sources
(require 'info)
(add-to-list 'Info-directory-list "~/my-emacs-config/caml-mode")
Here is the files in caml-mode (which contains ocaml.el)
bash-3.2$ ls ~/my-emacs-config/caml-mode/
caml-compat.el caml-emacs.el caml-font.el caml-help.el caml-hilit.el caml-types.el caml.el camldebug.el inf-caml.el ocaml.el
I did the following
--write an factorial func. in ocaml, called "annot.ml"
let rec f n =
if n = 1 then 0 else n * f(n-1)
--ocamlc -annot annot.ml
--open annot.ml by emacs and press "c-c c-t" while the cursor is under "n"
I got in the minibuffer of emacs
c-c c-t undefined
Conclusion, I still cannot retrieve types. Why??? Thank you for your ideas.
More info: when I try M-x caml-[tab] I get the following list, which does not contain caml-types-show-types
Possible completions are:
caml-mode camldebug
camldebug-backtrace camldebug-break
camldebug-close camldebug-complete
camldebug-delete camldebug-display-frame
camldebug-down camldebug-finish
camldebug-goto camldebug-kill
camldebug-last camldebug-mode
camldebug-next camldebug-open
camldebug-print camldebug-refresh
camldebug-reverse camldebug-run
camldebug-step camldebug-up
You're autoloading caml-mode from ocaml.el or ocaml.elc. But there is no such file! The official Caml mode is in a file called caml.el, and Tuareg mode is in a file called tuareg.el. This explains why opening your .ml file doesn't put you in Ocaml mode and doesn't load the Caml support. Change your autoload to either this to use the official mode
(autoload 'caml-mode "caml"
"Major mode for editing Caml code." t)
or this to use Tuareg mode
(autoload 'caml-mode "tuareg"
"Major mode for editing Caml code." t)

Code completion key bindings in Emacs

When doing a M-x describe-mode in a .el file, I noticed that the Emacs-Lisp mode actually does code completion. However, lisp-complete-symbol is bound to M-TAB. In Windows, this key binding is taken by Windows for switching the active window. Most IDE's use C-SPC, but that's taken in Emacs as well. What is a good, fairly common key binding for code completion?
If you like completion of all kinds, I recommend M-/ and binding that to hippie-expand.
(global-set-key (kbd "M-/") 'hippie-expand)
It does a variety of completions, which are controlled by the variable hippie-expand-try-functions-list. In the .el files, you can set that to do the 'try-complete-lisp-symbol first to get the behavior you're asking for above, along with all the other expansions hippie-expand provides.
This would do that for you:
(add-hook 'emacs-lisp-mode-hook 'move-lisp-completion-to-front)
(defun move-lisp-completion-to-front ()
"Adjust hippie-expand-try-functions-list to have lisp completion at the front."
(make-local-variable 'hippie-expand-try-functions-list)
(setq hippie-expand-try-functions-list
(cons 'try-complete-lisp-symbol
(delq 'try-complete-lisp-symbol hippie-expand-try-functions-list)))
(setq hippie-expand-try-functions-list
(cons 'try-complete-lisp-symbol-partially
(delq 'try-complete-lisp-symbol-partially hippie-expand-try-functions-list))))
As Trey Jackson mentioned, hippie-expand is the way to go, but along with binding it to M-/, I also like having the TAB key do all my completion work for me. So I have this from the Emacs-Wiki in my .emacs file:
;;function to implement a smarter TAB (EmacsWiki)
(defun smart-tab ()
"This smart tab is minibuffer compliant: it acts as usual in
the minibuffer. Else, if mark is active, indents region. Else if
point is at the end of a symbol, expands it. Else indents the
current line."
(interactive)
(if (minibufferp)
(unless (minibuffer-complete)
(hippie-expand nil))
(if mark-active
(indent-region (region-beginning)
(region-end))
(if (looking-at "\\_>")
(hippie-expand nil)
(indent-for-tab-command)))))
(global-set-key (kbd "TAB") 'smart-tab)
You could have hippie expand settings as follows:
;;settings for hippie-expand
(setq hippie-expand-try-functions-list
'(try-complete-lisp-symbol
try-complete-lisp-symbol-partially
try-expand-dabbrev
try-expand-dabbrev-from-kill
try-expand-dabbrev-all-buffers
try-expand-line
try-complete-file-name-partially
try-complete-file-name))
C-M-i; no customization required.
I use:
(define-key function-key-map [(control tab)] [?\M-\t])
I use M-. and M-/ for the 2 completion modes - hippie-expand and the standard emacs one.
Put this in your .emacs to make Windows give Emacs the use of M-TAB:
(when (fboundp 'w32-register-hot-key) (w32-register-hot-key [M-tab]))

Emacs: Tab completion of file name appends an extra i:\cygwin

I am facing some strange behavior with file-name completion in emacs. C-x C-f to find file opens up the minibuffer with i:/cygwin/home/rrajagop/StockScreener/working_copy/master_repo/stock_screener/. Hitting a TAB makes it i:/cygwini:/cygwin/home/rrajagop/StockScreener/working_copy/master_repo/stock_screener/. A couple of interesting things I've noticed:
When the minibuffer opens up, i:/cygwin is greyed out and the path seems to start from /home. A C-a (go to begining of line) takes me to /home and not to i:/cygwin. So it looks like something in emacs is parsing the path to start from /home and not from i:/cygwin.
I checked that TAB runs minibuffer-complete from minibuffer.el (by doing a describe-key for TAB), so it looks like minibuffer-complete is doing some translation for cygwin and appending the extra i:/cygwin.
How would I go about figuring this out/fixing it?
EDIT: Extra Information
I tried opening up emacs with -Q and this problem doesn't happen. So this is something I'm loading in my .emacs. This is what I have in my .emacs
(require 'cl)
; Needed to see how fast Emacs loads. Loading time is printed at the
; and of the execution of .emacs file.
(defvar *emacs-load-start* (current-time))
; I really like this font. I also tried Monaco which you can
; see on lot of Railscasts but I couldn't find the one which
; supports Serbian Cyrillic and Latin letters.
(set-default-font "-outline-Courier New-normal-r-normal-normal-19-142-96-96-c-*-iso8859-1")
;; Don't show that splash screen
(setq inhibit-startup-message t)
; This should allegedly speed up Emacs starting by preventing
; some requests from the window manager back to the Emacs. Frankly
; speaking I didn't notice some speed up but I still keep it:(
(modify-frame-parameters nil '((wait-for-wm . nil)))
;Allows syntax highlighting to work, among other things
(global-font-lock-mode 1)
; Sets initial window position
(set-frame-position (selected-frame) 0 0)
; Sets initial window size to 85 columns and 47 rows
(set-frame-size (selected-frame) 88 32)
; Makes last line ends in carriage return
(setq requre-final-newline t)
; Sets Ctrl-x / key combination for easy commenting
; out of selected lines.
(global-set-key "\C-x/" 'comment-or-uncomment-region)
; Allow resizing of the mini-buffer when necessary
(setq resize-minibuffer-mode t)
; Auto magically read compressed files
(auto-compression-mode 1)
; Set standard indent to 2 rather then 4
(setq standard-indent 2)
; This tells Emacs to create backup files.
(setq make-backup-files t)
; And this will enable versioning with default values.
(setq version-control t)
; Remove annoying message about deleting excess backup of .recentf
; which is list of recent files used
(setq delete-old-versions t)
; Finally do not spread backups all over the disk.
; Just save all backup files in this directory.
(setq backup-directory-alist (quote ((".*" . "~/.emacs_backups/"))))
;; Directory to put various el files.
(add-to-list 'load-path "~/.emacs.d/includes")
(require 'ascii-table)
;; Loading collection of generic modes for different languages
(require 'generic-x)
;; Recent files
(require 'recentf)
(recentf-mode 1)
;; Loads ruby mode when a ruby file is opened.
(autoload 'ruby-mode "ruby-mode" "Major mode for editing ruby scripts." t)
(setq auto-mode-alist (cons '(".rb$" . ruby-mode) auto-mode-alist))
(setq auto-mode-alist (cons '(".rhtml$" . html-mode) auto-mode-alist))
(setq auto-mode-alist (cons '(".html.erb$" . html-mode) auto-mode-alist))
;; Turn on ruby electric (auto completion of parenthesis, etc.)
(add-hook 'ruby-mode-hook
(lambda()
(add-hook 'local-write-file-hooks
'(lambda()
(save-excursion
(untabify (point-min) (point-max))
(delete-trailing-whitespace) )))
(set (make-local-variable 'indent-tabs-mode) 'nil)
(set (make-local-variable 'tab-width) 2)
(imenu-add-to-menubar "IMENU")
(define-key ruby-mode-map "\C-m" 'newline-and-indent)
(require 'ruby-electric)
(ruby-electric-mode t) ))
;; Ruby debugging.
(add-to-list 'load-path "~/.emacs.d/plugins/rdebug")
(autoload 'rdebug "rdebug" "Ruby debugging support." t)
(global-set-key [f9] 'gud-step)
(global-set-key [f10] 'gud-next)
(global-set-key [f11] 'gud-cont)
(global-set-key "\C-c\C-d" 'rdebug)
;; set compile command based on current major mode
(autoload 'mode-compile "mode-compile"
"Command to compile current buffer file based on the major mode" t)
(global-set-key "\C-cc" 'mode-compile)
(autoload 'mode-compile-kill "mode-compile"
"Command to kill a compilation launched by `mode-compile'" t)
(global-set-key "\C-ck" 'mode-compile-kill)
;; yasnippet - adding code snippet insertion
(add-to-list 'load-path "~/.emacs.d/plugins/yasnippet")
(require 'yasnippet) ;; not yasnippet-bundle
(yas/initialize)
(yas/load-directory "~/.emacs.d/plugins/yasnippet/snippets")
;; Use CYGWIN bash
(require 'setup-cygwin)
;; Subversion integration via psvn - not gonna use svn anymore
;; (require 'psvn)
;; add some elisp tutorials to the info directory
(let ((info-root (concat usb-drive-letter "cygwin/usr/local/bin/emacs/info/")))
(setq Info-directory-list (list info-root
(concat info-root "elisp-tutorial-2.04/")
(concat info-root "emacs-lisp-intro-2.14")) )
)
;; Load time for .emacs - this should be the last line in .emacs for accurate load time
(message "ido and org-install took: %ds"
(destructuring-bind (hi lo ms) (current-time)
(- (+ hi lo) (+ (first *emacs-load-start*) (second *emacs-load-start*)) )))
I think my answer to your previous question on finding the package loading tramp will help you out here.
you can control tramp by changing the variable tramp-mode.
Side note, you would probably find it useful to use customize to customize emacs.
I did a customize-apropos with tramp and it found the tramp group. Clicking there showed all the ways to configure tramp, including turning it off.
File-name-shadow-mode greys out the c: in the file name..... so when cygwin-mount-substitute-longest-mount-name runs it does no see the c: and adds another
M-x find-file
c:/home/
> a
c:/home/a ; but the c: is greyed
> TAB
c:c:/home/anything