GNU Emacs closing beginning/end of buffer sound - scroll

I just started on GNU emacs, but I want to close the sound (windows not-allowed sound?) when I try to scroll end of buffer, or beginning of buffer. I searched options page (or prefereces) in emacs, I can't find it. Anyone know any solution (excepts closing speaker :)

Add (setq visible-bell t) to your .emacs

Related

emacsclient, restore all windows in a frame in terminal

The object: In terminal, on start, in one frame, restore emacs workspace. i.e. restore all "windows", to the state before C-x C-c.
Descriptions: The window restoration could be simply done in emacs GUI, by adding (desktop-save-mode 1) to the init.el file.
However, when running emacs as a Daemon, emacsclient does not perform the same way. With the same setup, it still remember the major mode of the file, as well as other buffers before exiting, but the window layout will not be restored. Only 1 major window is displayed depend on the default settings.
I did some research, poked into some functions/variables using the elisp build-in documentation. I checked (desktop-save-buffer 1), framset-save, framset-restore and none of them seems to work. Also I checked similar questions posted before, and I found someone's answer using the following script:
(setq desktop-restore-forces-onscreen nil)
(add-hook 'desktop-after-read-hook
(lambda ()
(frameset-restore
desktop-saved-frameset
:reuse-frames (eq desktop-restore-reuses-frames t)
:cleanup-frames (not (eq desktop-restore-reuses-frames 'keep))
:force-display desktop-restore-in-current-display
:force-onscreen desktop-restore-forces-onscreen)))
However this script is buggy, it opens a "GUI" frame, and could not be closed properly(reopen automatically whenever closed, and if possible, I prefer to open the frame in terminal, so that a terminal 'texteditor' setting is possibe, with some other minor merits).
Sorry for the tedious question, any help would be appreciated.
I don't really know the right way to do this, but I was able to restore a frameset created in a GUI frame into a terminal frame. The new frame must be big enough or it will throw an error. I did (setq foo (frameset-save (frame-list))) and (pp foo (get-buffer "*scratch*")) to dump a readable representation of the frameset to the *scratch* buffer. Then I edited it by hand to get rid of (display . ":0.0"). That seemed to be enough to get it to not force a GUI frame. Then I did (frameset-restore [frameset ...]) on the edited frameset.
If you look at frameset.el, there are filtering functions to edit a frameset programmatically. Also, if you look at the comments, the display parameter is treated specially. You should look at the details there.

Combining the kill-ring and clipboard in Aquamacs on OSX

#lawlist asked for more details so I am re-writing the question:
My goal is to treat ^X and ^K as two different ways to cut text into a SINGLE
logical clipboard that can be pasted using ^V in emacs or in any other app.
Suppose there are two lines in the emacs buffer:
I am line one
I am line two
and I press ^K on the first line, then the kill ring AND the OS-level clipboard
BOTH now have 'I am line one' by pressing ^K two more time, then the OS-level clipboard will be updated again to have "I am line one\nI am line two"
Pressing ^V in emacs or in other applications will cause that text to be pasted into them. (^Y can continue to have its original behavior, or not, I don't care)
Right now, ^K is bound to org-kill-line or just kill-line depending on which edit mode I am in.
I don't think there is an existing emacs command to do this, but
if only I knew the functions to call, I bet it is trivial to simply
update the OS clipboard after every ^K.
Any help would be great.
thanks,
dan
I think you are looking for save-interprogram-paste-before-kill. Try adding this
(setq save-interprogram-paste-before-kill t)
to your init.el

Why does shell mode display some rubbish code?

When I use bower in M-x shell, as you can see in the picture, some rubbish code is displayed.
However M-x ansi-term works well
What could be the problem ? Is it possible to make shell mode display properly ?
Those symbols are ANSI escape sequences that the terminal emulator uses for visual effects like changing the color of text. shell-mode apparently doesn't know how to display these codes by default. What you want may be Term Mode:
Some programs (such as Emacs itself) need to control the appearance of the terminal screen in detail. They do this by emitting special control codes. Term mode recognizes and handles ANSI-standard VT100-style escape sequences, which are accepted by most modern terminals, including xterm. (Hence, you can actually run Emacs inside an Emacs Term window.)
Try the solution given in Cucumber's ANSI colors messing up emacs compilation buffer:
(require 'ansi-color)
(defun colorize-compilation-buffer ()
(toggle-read-only)
(ansi-color-apply-on-region (point-min) (point-max))
(toggle-read-only))
(add-hook 'compilation-filter-hook 'colorize-compilation-buffer)
that works beautifuly for me on emacs24.
ps: to colorize even more the shell output I like to play with
M-x highlight-regexp RET a regexp, i.e. \[OK\] RET a color (make use of TAB to see choices)
or
(add-hook 'shell-mode-hook (lambda () (highlight-regexp "\\[OK\\]" "hi-green-b")))
and (add-hook 'shell-mode-hook (lambda () (goto-address-mode ))) to make URLs clikable. Looking for the same stuff for file paths.
edit: making file paths clickable is as easy as using compilation-shell-minor-mode :)
edit2: my sources: http://wikemacs.org/index.php/Shell
WRT to bash, sometimes setting $PAGER helps here, i.e.
PAGER=cat

Shift-selection and emacs 24

I use emacs 24 (OSX) and have a problem with shift-selection.
If I select a region with my mouse, the text is highlighted and automaticaly saved on to the kill ring (I can yank it immediately).
With shift-selection, the text is highlighted but I have to manualy save the text (M-w) to be able to yank it.
Is there any way that shift-selection hightlights the text AND saves it onto the kill ring ?
Selecting text with the mouse does not place anything onto the kill ring by default (it copies it to the X clipboard).
There are various ways in which you can customise how Emacs interacts with the clipboard. See:
C-hig (emacs) Cut and Paste RET
Is there any way that shift-selection hightlights the text AND saves it onto the kill ring ?
I'm not sure that there's any way to detect that you've stopped selecting things, but you could perhaps advise handle-shift-selection to set a temporary post-command-hook to run a custom function to place the region in the clipboard (and remove the post-command-hook).
Edit: Hang on, what you describe is exactly what happens for me in Emacs 24.1 on Ubuntu.
If I shift-select some text in Emacs and then middle-click the mouse in any application, I paste the selected text.
Try testing when running emacs -Q
Edit 2: Ah, but you didn't mean the mouse, did you?
How about this?
(defvar my-shift-selection-in-progress nil)
(make-variable-buffer-local 'my-shift-selection-in-progress)
(defadvice handle-shift-selection
(before my-shift-selection-to-kill-ring-advice)
"Automatically copy shift-selected text to the kill ring.
If `interprogram-cut-function' is non-nil, also save the text for a window
system cut and paste.
See `my-shift-selection-to-kill-ring'."
(when (and shift-select-mode
this-command-keys-shift-translated
(not my-shift-selection-in-progress))
(add-hook 'post-command-hook 'my-shift-selection-to-kill-ring nil t)))
(ad-activate 'handle-shift-selection)
(defun my-shift-selection-to-kill-ring ()
"Post-command callback for my-shift-selection-to-kill-ring-advice."
(if this-command-keys-shift-translated
(kill-new (filter-buffer-substring (region-beginning) (region-end))
my-shift-selection-in-progress)
(remove-hook 'post-command-hook 'my-shift-selection-to-kill-ring t))
(setq my-shift-selection-in-progress this-command-keys-shift-translated))
The problem with "auto-kill from shift-selection" is to determine when the shift-selection ends (at which point you can finally do the kill).

Emacs M-x commands for invoking "GUI-style" menus

Question: How could I find out the M-x equivalent commands for doing GUI-based operations in Emacs, in those cases where my Emacs-variant uses OS-specific desktop functionality?
Background: Conventional understanding states that everything in Emacs is a command, and that commands can be invoked via M-x, as long as you know the name of the command. Assuming this statement is correct, what is the way to find the name of the commands used to trigger the "GUI-style" menus in a "desktop" based Emacs variant?
For example, if I were to mouse-select the File menu to open a file, the OS-specific "GUI" style file-open dialog pops up, waiting for my input.
How could I find out the M-x equivalent command for doing the exact same thing?
I thought that describe-key would tell me what I needed to know, but it's indication to use:
M-x menu-find-file-existing
doesn't invoke the "GUI" style file-open dialog. Instead, it uses the Emacs internal non-GUI-OS-neutral variant.
You need to trick Emacs into thinking that the keyboard was not being used, which is not as intuitive as tricking it into thinking that the mouse was used. :)
(defadvice find-file-read-args (around find-file-read-args-always-use-dialog-box act)
"Simulate invoking menu item as if by the mouse; see `use-dialog-box'."
(let ((last-nonmenu-event nil))
ad-do-it))
Tested on Emacs 22.2.1 on WinXP. I believe the paradigm has been around for a while, though, so it should work on older Emacs. No clue if XEmacs works similarly or not.
Wow, I'm glad you asked that. I've been meaning for a while to look it up myself.
C-h k followed by the menu choice will tell you this. Here, for example, is what you get from choosing menu/edit/paste:
<menu-bar> <edit> <paste> runs the command clipboard-yank
which is an interactive compiled Lisp function in `menu-bar.el'.
It is bound to <paste>, <f18>, <menu-bar> <edit> <paste>.
(clipboard-yank)
Insert the clipboard contents, or the last stretch of killed text.
If you want the details, follow the link for menu-bar-el to the LISP source:
(defun menu-find-file-existing ()
"Edit the existing file FILENAME."
(interactive)
(let* ((mustmatch (not (and (fboundp 'x-uses-old-gtk-dialog)
(x-uses-old-gtk-dialog))))
(filename (car (find-file-read-args "Find file: " mustmatch))))
(if mustmatch
(find-file-existing filename)
(find-file filename))))

Resources