texts: Why do symbols become suddenly defined right after startup?

texts:
Below is an example of the situation described in the question's title, using the variable prolog-mode-version as test case.

If my Emacs init file consists of just the code shown below:

(defun show-pmv (hook-name)
  (let ((pmv (if (boundp 'prolog-mode-version)
                 prolog-mode-version
               "undefined")))
    (message "%s: prolog-mode-version: %s" hook-name pmv)))

(add-hook 'after-init-hook    (lambda () (show-pmv "after-init")))
(add-hook 'emacs-startup-hook (lambda () (show-pmv "emacs-startup")))
(add-hook 'window-setup-hook  (lambda () (show-pmv "window-setup")))

(setq inhibit-startup-screen t)
(switch-to-buffer "*Messages*")

...and I start up Emacs, my *Messages* buffer contains the following

after-init: prolog-mode-version: undefined
For information about GNU Emacs and the GNU system, type C-h C-a.
emacs-startup: prolog-mode-version: undefined
window-setup: prolog-mode-version: undefined

...but if, right after startup, I inspect the value of prolog-mode-version (using C-h v), I get a non-void value ("1.22").

The variable prolog-mode-version is not an isolated case.  In fact, many other symbols defined in prolog.el seem to be available right after startup, even though my init file does not load/require this package.

I find this extremely confusing.

Why do symbols that were void during startup become suddenly defined right after startup?

Conversely, is there some way for my init file to access the value of prolog-mode-version?

(Related.)


texts: How do I kill all buffers that were opened from browsing rgrep results?

texts:
I had a set of buffers open that I want to keep.

Then I started a search with M-x rgrep (SPC f g on Spacemacs).

While browsing results with n and p, each file containing a result is opened in a new buffer.

After I'm done with the search and browsing, I'm left with dozens of buffers open that I no longer want.

They are in the same project as I have the buffers I want to keep, so I can't just M-x projectile-kill-buffers.

Is there any other way?


texts: How do I move the cursor to the *Warnings* buffer whenever there is a new warning?

texts:
I want to focus the *Warnings* buffer whenever there is new warning. I tried this:
(add-hook 'special-mode-hook
          (lambda ()
            (when (string= (buffer-name (current-buffer))
                           "*Warnings*")
              (pop-to-buffer (current-buffer)))))

However, the cursor only moves to the *Warnings* buffer on the first warning. Subsequent warnings do not move to the cursor to the *Warnings* buffer. What do I need to do to move the cursor to the *Warnings* buffer whenever there is a new warning?
Emacs version: GNU Emacs 26.3.


texts: How to map a function over several values?

texts:
I have a function foo-function that takes the variable x and performs a specific action.  The variable x comes before the definition of foo-function:

(defvar x "value1")

(defun foo-function ()
  (blabalabla x))

I would like to define a new function foo-function2 which takes several variables value1, value2, value3, .... of x (the number of variables is indeterminate) and runs the function foo-function for these variables, i.e., the following action:

(foo-function2 "value1" "value2" "value3", ...)

It should result in the execution of foo-function for the values value1, value2, value3, .... of x.

How do I define this function?


texts: How do I change only what "dd" does in evil-mode's normal-state in a minor mode

texts:
When I press dd in haskell-interactive-mode at the prompt, it doesn't delete anything, because part of the line is read-only. I would like to map dd to 'haskell-interactive-mode-kill-whole-line.

this

(evil-define-key 'normal haskell-interactive-mode-map
  (kbd "dd") 'haskell-interactive-mode-kill-whole-line)

doesn't solve the problem. Although it binds dd, it clobbers evil-mode's d binding, making commands like dw no longer work. Just adding things to the evil-operator-shortcut-map (like what evil-surround does) doesn't quite cut it either, because that would bind nonsensical sequences like yd which should remain unbound.

These two links are relevant, but not quite answers.


texts: How can I quickly toggle between a file and a *scratch* buffer having the same major mode?

texts:
At times while working on a code, it's useful to quickly open a *scratch* buffer to paste a snippet from that code file.

If I am working on a Perl script, I would like to quickly open a *scratch* buffer with in cperl-mode. It would also be nice to quickly jump back to the code buffer I was originally working in.


texts:
What is the command for Emacs/Spacemacs to select the surrounding (logical) block?

I know I've used this some time ago, I just don't remember how exactly :)


texts: Automatically add project directory to flycheck clang/gcc include path

texts:
I want to use syntax checking with Flycheck in my C++ projects, but the Clang checker fails to find the local file includes. For example, when I have:

#include "foo/bar/x.h"

in the file foo2/y.cc, it reports an error that it couldn't find the include file. Both foo/ and foo2/ are in the project root. I can work around this by adding the following to a .dir-locals.el file in the project:

((c++-mode .
     ( (flycheck-clang-include-path . "/home/user/src/myproject") ) )
     ))

However, I have dozens of projects and it would be a lot of work to set this for each directory. I'm using Projectile and I think it should be possible to set the include path based on the project root automatically, but I cannot find any variable or function in Projectile that would return the path to the current project.


texts: How to let-bind multiple variables conditional on X?

texts:
Q: how can I let-bind multiple variables conditional on x?

Assume that I have three variables, a, b, and c, that I want
to let-bind conditional on some other x.  How do I do that
concisely and idiomatically?

Here's an example that works, but is repetitive and error-prone:

(let ((a (if t 1 4))
      (b (if t 2 5))
      (c (if t 3 6)))
  (list a b c))                         ; => (1 2 3)

Here's another example that works, but the use of setq feels
both repetitive and inelegant:

(let (a b c)
  (if t
      (setq a 1
            b 2
            c 3)
    (setq a 4
          b 5
          c 6))
  (list a b c))                         ; => (1 2 3)

Here's an example that doesn't work, because the variables fall
outside the scope of the let-binding:

(if t
    (let ((a 1)
          (b 2)
          (c 3)))
  (let ((a 4)
        (b 5)
        (c 6)))
  (list a b c))                         ; => nil

What is the idiomatic way to do this?


texts:
Seems that src/keyboard.c file contains C string arrays for (info "(elisp) Function Keys").

Is there a way to get that list in Elisp?

I discovered that such symbols have special properties:

(symbol-plist 'backspace)
==> (event-symbol-element-mask (backspace 0) event-symbol-elements (backspace) ascii-character 127 event-kind function-key modifier-cache ((8388608 . s-backspace) (201326592 . C-M-backspace) (134217728 . M-backspace) (67108864 . C-backspace) (0 . backspace) (100663296 . C-S-backspace)))

But some of them:

(symbol-plist 'XF86AudioPlay)

are empty until I press corresponding key.

For all pressed keys it is:

(mapatoms (lambda (ob) (when (eq (get ob 'event-kind) 'function-key)
                    (message "%s" ob)))
            obarray)

You ask why? Because I dig in Emacs internals...


texts: Easiest way to check if current line is "empty" (ignoring whitespace)?

texts:
I just want to check if the  current line is empty or not (if it contains only whitespace, then I still consider it empty).

Here is my initial version:

(defun strip-text-properties(txt)
  (set-text-properties 0 (length txt) nil txt)
  txt)

(defun is-current-line-empty ()
  (interactive)
  (setq c-line (thing-at-point 'line))
  (string-match "^\s*$" (strip-text-properties c-line)))

What is the easiest way to check if current line is empty?


texts: Unset key "C-;" in Aquamacs, bound to toggle-mac-option-modifier

texts:
I use Aquamacs. C-; is bound to toggle-mac-option-modifier. When I use C-h k C-;, I get

  ^; runs the command toggle-mac-option-modifier, which is an
  interactive Lisp function in `emulate-mac-keyboard-mode.el'.

I want to remove this keybinding so I can use elsewhere. I have tried

(global-unset-key (kbd "C-;"))
(define-key toggle-mac-option-modifier [C-\;] nil)
(define-key emulate-mac-keyboard-mode [C-\;] nil)
(define-key emulate-mac-keyboard-mode [?\C-\;] nil)
(define-key emulate-mac-keyboard-mode [C-\;] nil)
(define-key emulate-mac-keyboard-mode [control-\;] nil)
(define-key emulate-mac-keyboard-mode-map [control-\;] nil)
(define-key emulate-mac-keyboard-mode [control \;] nil)
(define-key emulate-mac-keyboard-mode (kbd "C-;") nil)
(define-key toggle-mac-keyboard-modifier (kbd "C-;") nil)
(define-key toggle-mac-option-modifier "C-;" nil)

I keep getting the error that the

  symbol's value as variable is void

After much searching I found somewhere that maybe the value of the variable had not been initialised, so I tried those after

(require 'emulate-mac-keyboard-mode)

with the same result. I also tried

(eval-after-load 'emulate-mac-keyboard-mode
  '(progn
     (define-key emulate-mac-keyboard-mode [C-\;] nil)))

How can I unset this key?


texts: Enable org-agenda-clockreport-mode in TODO agenda view

texts:
Is there any way to enable clockreport-mode in a TODO-agenda view? I mainly use this view because I don't really set dates for my tasks so the agenda-view is not really helpful for me (I'm using spacemacs by the way).

Anyway the clockreport-mode only works in 'agenda' - Agenda-Buffers. Otherwise it will throw an error Not allowed in todo-type agenda buffers.

The function in org-agenda.el is defined like this:

(defun org-agenda-clockreport-mode ()
"Toggle clocktable mode in an agenda buffer."
(interactive)
(org-agenda-check-type t 'agenda)
(setq org-agenda-clockreport-mode (not org-agenda-clockreport-mode))
(org-agenda-set-mode-name)
(org-agenda-redo)
(message "Clocktable mode is %s"
       (if org-agenda-clockreport-mode "on" "off")))

And I think this is where the clocktable gets inserted in defun-org-agenda-list

  (when (and org-agenda-clockreport-mode clocktable-start)
(let ((org-agenda-files (org-agenda-files nil 'ifmode))
      ;; the above line is to ensure the restricted range!
      (p (copy-sequence org-agenda-clockreport-parameter-plist))
      tbl)
  (setq p (org-plist-delete p :block))
  (setq p (plist-put p :tstart clocktable-start))
  (setq p (plist-put p :tend clocktable-end))
  (setq p (plist-put p :scope 'agenda))
  (setq tbl (apply 'org-clock-get-clocktable p))
  (insert tbl)))

But as im still an Elisp novice I don't really know what I can do to enable and display a clocktable in a todo-agenda Buffer.

Edit:

Thanks to Tobias answer I found a way to work around the problem so that it fits my use case. This avoids using org-agenda-clockreport-mode, so I guess it doesn't really answer the question but it's good enough for me right now.

I took the clocktable code from org-agenda.el and modified it slightly to turn it into my own function that can insert a clocktable.

(defun own-clock-report ()
  "function to insert clocktable"
(goto-char (point-max))
(let ((org-agenda-files (org-agenda-files nil 'ifmode))
      ;; the above line is to ensure the restricted range!
      (p (copy-sequence org-agenda-clockreport-parameter-plist))
      tbl)
  (setq p (org-plist-delete p :block))
  (setq p (plist-put p :tstart "<today>"))
  (setq p (plist-put p :tend "<now>"))
  (setq p (plist-put p :scope 'agenda))
  (setq tbl (apply 'org-clock-get-clocktable p))
  (open-line 1)
  (insert tbl)))

Then I used a hook to add it to my agenda view:
(add-hook 'org-agenda-finalize-hook #'own-clock-report)

Using org-agenda-mode-hook seems to work as well, if you like the clockreport on top of the agenda.

The only drawback this method has is, that every time I change the Todo-state of an item or clock in/out of it, a clocktable appears below the item and I have to rebuild the agenda buffer to make it disappear.


texts: Is there a way to detect change of monitor in Emacs / Elisp?

texts:
tl;dr I'm looking for way to detect when an Emacs frame has been moved from one monitor to another in a multi-monitor setup.

I have code in my ~/.emacs which sets the default font size for all displayed buffers in a frame based on the physical size and resolution of the monitor hosting the Emacs frame. In a multi-monitor setup, I would like to execute the font-sizing logic when a frame is moved from one monitor to another with possibly different rez + physical dimensions.

I've not found a way to do this in stock Emacs (have been looking mostly at available hooks) nor have I found any community code which might, say, add a hook for monitor change events.


texts: Changing font of non-monospace text in Emacs

texts:
I see variable and function names in Info pages rendered with a different font in Emacs recently, how can I change this font?

For example, here ^ this-comamnd and last-command are in a font. I would like to customize this font. I think this same font is used in eww and I find it ugly, eww.


texts: How to temporary disable yassnipet snippet in snippet

texts:
I'm new to yassnipet and it's been awesome but I hit a wall.
I have the following snippet:

$1 = errors.WithMessage($1, $2))$0

In most of the use cases on $1 I enter err which expands to another snippet.

I would like to temporary disable yas-triggers-in-field for this snippet only, is there a way to do it?


texts: In vanilla Emacs, I have to do C-x b and then manually type out the buffer name to switch. If I forget the  name of the buffer, I have to hit TAB to list possible completions. Is there anything I can do to make this process faster?


texts: how make "magit log" show entire log message

texts:
I have a commit with a message like this:

Contact Inquiries

todo: current user detection
import old table
actionmailer + mailgun

Magit log only shows "Contact Inquiries", and not the other 4 lines.
How can I make magit show me full message in the log.


texts:
In emacs M-x command-name can be used to invoke a command.
However in Mac M1, for some reason, this is not working.
Basically, I am trying option + x or M-x.
Any idea about this?


texts: when I export org file into HTML or LaTex, the source code in the block cannot fold, Is there any setting can fold the text inside the source code block?


texts: How can I make emacs monochrome in no-window-system mode?

texts:
I prefer to run emacs as a console application, and I would prefer that it be monochrome. I currently have (global-font-lock-mode 0) set in my init file, which works as I want it to on my mac. However, on my new debian laptop, I find that this (correctly) disables syntax highlighting in the body of files, but text in the echo area is showing in blue, which is hard to read on a black background.

Is there a way to ask emacs to be entirely monochrome?


texts: How can I export compositions with html-fontify?

texts:
Prettify-symbols-mode is a very nice way to make source code more readable, especially in math-heavy languages. Unfortunately, exporting to HTML with html-fontify-buffer doesn't respect prettifications.

It can be made to (I wrote the code for that), but it breaks copy-pasting (the prettified symbols are copied, not their unprettified equivalents).

In other words, how can I export an Emacs lisp buffer to a webpage, while preserving prettifications and not breaking copy-paste?


texts: Is there a function for logging to *Messages* buffer without displaying in the echo-area?

texts:
Is there a function for logging to Messages buffer without displaying in the echo-area?  Or maybe another build in log mechanism?

I'm after a kind of console.log("string") kind of functionality.


texts: How to start emacs in "nothing" mode (`fundamental-mode`)

texts:
If I type emacs test.sh Emacs insists on putting me in Shell-script mode. Another time I want to edit the file help.txt and then Emacs puts me in Text mode. But sometimes I don't want any of this, especially when I am doing a large paste into Emacs from some other source.

How do I start Emacs in "nothing" mode? No special indenting, spacing, etc., and Emacs simply takes the characters in as they are entered.

UPDATE: Here is an example. Copy the following text to your clipboard, open emacs (even in fundamental mode) and paste.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<EntityDescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
xmlns:shibmd="urn:mace:shibboleth:metadata:1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 ID="FARM20190311T2248"
 Name="https://www.example.com/"
 entityID="https://www.example.com/" validUntil="2020-03-11T22:48:12Z"><ds:Signature>
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>

Emacs insists on changing the spacing (even in fundamental mode and using -q) to this:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<EntityDescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
xmlns:shibmd="urn:mace:shibboleth:metadata:1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 ID="FARM20190311T2248"
  Name="https://www.example.com/"
   entityID="https://www.example.com/" validUntil="2020-03-11T22:48:12Z"><ds:Signature>
   <ds:SignedInfo>
   <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>

Try the same experiment with vi or nano. Those programs (at least on my computer) do not change the spacing.

I am using GNU Emacs 24.5.1 on Debian stretch.


texts: Dvorak input mode wrong letters when typing fast, correct, when typing slow

texts:
I have dvorak keyboard layout set as input when I am in evil-input mode. However, when I type relatively fast when typing the I get thd. This is just an example, some other "typos" occur as well. This doesn't occur, however, when I am typing slowly.
I would assume this happens because in dvorak layout e is where letter d is in the standard layout (i.e. somehow emacs doesn't manage to remap it).
How can I prevent such typos from occurring?
My config is:
(after! evil
  (setq evil-escape-key-sequence "hk")

  (add-hook! 'evil-insert-state-entry-hook
    (activate-input-method "english-dvorak")))


texts:
How do I go about removing the message "When done with this frame, type C-x 5 0" when launching emacsclient?

I know it's possible to controll the startup message of emacs when not launched as a daemon by changing the display-startup-echo-area-message function, but it has no effect when I launch emacs with "emacsclient -c"


texts: Arrow and M-n M-p don't work with company mode in terminal when ESC aborts completion

texts:
In a terminal window, I'm finding that company-mode completion doesn't work, whereas it does work in a graphical window. For example a down arrow inserts the text OB and M-n simply inserts n.

As a workaround, I've followed this answer to use C-n and C-p like so

(with-eval-after-load 'company
  (define-key company-active-map (kbd "C-n") #'company-select-next)
  (define-key company-active-map (kbd "C-p") #'company-select-previous))

but I'd prefer to use the same keys whether I'm running graphically or via ssh.

This used to work, and I've upgraded my configuration files and installed a lot more packages recently, but even reducing my initialization file down to just the company mode code didn't fix the problem.

Edit: I've isolated the problem down to this line of code that I copied from the graphene package that redefines ESC to abort the completion.

 (define-key company-active-map (kbd "ESC") 'company-abort)

I can see how this might stop M-n and M-p working because ESC has got something to do with the Alt key in emacs. I can workaround the problem in a terminal using

(if (display-graphic-p)
    (with-eval-after-load 'company
      (define-key company-active-map (kbd "ESC") 'company-abort)))

which means that single ESC aborts completion in a graphical frame, and triple ESC aborts in a terminal.

However is it still be possible for the arrow keys to work with single ESC? My preference is to use arrow keys and single escape if possible.


texts:
I'm performing a large python refactor, and one component of that is renaming many variables from camelCase to snake_case. I'd like to hook a camel-to-snake conversion function (which I already have) into the default values of rope-refactor.

When I inspect rope-refactor, I get the following information.

rope-rename is an interactive Lisp function.

(rope-rename &rest ARGUMENTS)

It interfaces to a Python function.

Rope interfaces with Emacs through Pymacs. What would be the recommended way of achieving these defaults? Should I make the change in Rope's python modules, or is there an elegant way of setting the default arguments on the elisp side? I'd prefer the latter.


texts:
I'd like to use a super small value of company-minimum-prefix-length, for example, 2. This is really handy and I don't feel any performance issue. The only thing that annoys me is, when in inferior shell mode(inferior-python-mode, inferior-ess-mode, shell-mode ...), some commands are short, i.e. ls, what I actually want is to run the command after I press RET even there was company tooltip displaying the candidates before I press RET. But what I got is company did the completion and I need to press RET to run the command.

Because this will happen even when company-minimum-prefix-length is set to a large value, for example, 5,

Rather than set a larger value of company-minimum-prefix-length, I'd like to tell company to do completion and and run the command of RET of current major mode if current candidate is already exactly the same as the prefix I typed ? Thanks in advance.


texts: Copy all dirs exclude all subdirs with name "build"

texts:
emacs 26.1

dired+

I have dir my_dir. This dir contains 10 subdirs. In every of those dirs there are 2 subdirs:

src
build

I need to copy in DIRED MODE all dirs and files from my_dir to my_dir2 and exclude all subdirs with name build.

Is it possible?

P.S. subdirs build content thousands files. So copy without this folders is much faster.

P.P.S.
Here approach how I can do this in Total Commander.

I use file types like this:

*.* | build\

As result while copying , then copy all dirs exclude all subdirs build. It's very simple and comfortably.

Is it possible this approach same on Emacs ?


texts: (file-name-directory #$): How does Emacs know what #$ is?

texts:
I see that a few packages, and package.el use (file-name-directory #$).  How does Emacs know what directory #$ is?  On OSX, that returns Wrong type argument: stringp, nil.

Excerpt from cl-lib.el when installing a package evil-mc through the package manager, which goes into cl-lib-autoloads.el and then Emacs chokes:

;; First line of defense: try to make sure the built-in cl-lib comes earlier in
;; load-path so we never get loaded:
;;;###autoload (let ((d (file-name-directory #$)))
;;;###autoload   (when (member d load-path)
;;;###autoload     (setq load-path (append (remove d load-path) (list d)))))


texts: How to display a python string in the modeline?

texts: I'm using a python script to get my monthly bandwith usage shown as string on the terminal stdout. How can I display & update it periodically in the modeline?


texts: How to prevent emacs theme to load when running on terminal

texts: Hi I'm asking this question because this;[1]: Different theme for -nw (terminal) and few others didn't work for me. Allright, first of all I am not a programmer/devoloper, and I don't know lisp (thinking about learning it, but too busy). The problem I encountered is when I use emacs on gui with standart theme, it hurts my eyes, and the theme is just ugly. But when I use it on terminal (emacs -nw with no theme) it is beautiful because of the terminal theme/compton etc. Sometimes I have to use gui for a quick edit on desktop files or some other files, I'd like to ask you, how can I achive, to run emacs with some theme when on gui, and no theme on terminal.[2]: https://www.gnu.org/software/emacs/manual/html_node/elisp/Display-Feature-Testing.html I've seen this part of gnu/emacs manual, I understood what the "display-graphic-p" and "if" codes do but not sure how to use it,  because I don't want any other theme to load on emacs when I use it on terminal.


texts:
Are there any useful functions / modes / hydras / utilities for navigating xml documents?

Some features that might be nice to have:

Jump to parent
Jump to next child
Jump to matching tag (like % in vim)
Helm go to ancestor
Helm to to child

Things that I have found so far

Commands sgml-skip-tag-forward and sgml-skip-tag-backward. There is an sgml-tag-end function by this is not interactive and wants to take an argument.


texts:
I have emacs set up to indent Python code like so:

foo(
    bar, baz
)

That works fine.  However, that style in a particular program I'm working on very often means I find myself with text like this:

some_very_long_python_function_call(an_extremely_long_name_here, and_another_one_right_here)

At which point I'd like to be able to ask emacs to reformat that line, or sexp if you like (the one at point, let's say), like this:

some_very_long_python_function_call(
    an_extremely_long_name_here, and_another_one_right_here
)

or possibly like this:

some_very_long_python_function_call(
    an_extremely_long_name_here,
    and_another_one_right_here
)

Is there a way to do that?  Just using regular editing keys I find it a bit of a chore.


texts: How can I keep Customize value menus from running too long to select?

texts:
I've been trying to set org-babel-load-languages using Customize in Cocoa Emacs 24.4 (and using Emacs in a text console).

When I click INS then Choice: Value Menu, I get a widget-choose buffer with a list of choices that looks like this:

0 = Awk
1 = C
2 = R
3 = Asymptote
4 = Calc
5 = Clojure

etc. etc. all the way to the bottom of that buffer, and beyond.

I can't see either of the languages I'd like to choose (Python and Ruby), so I can't figure out the corresponding letter to press to pick one of them. When I try to click in that buffer to scroll, it closes and pops me back into the Customize buffer. Same with attempts to switch into it with C-o and scroll that way.

I've worked around it by setting a choice, saving, then editing my Customize-set variables to suit, but that's annoying.

Is there any way to compel better behavior from that widget-choose buffer?


texts: writing tests for a post-self-insert-command hook

texts:
I wrote a minor mode with the purpose of modifying written text on the fly.

It is currently creating a post-self-insert-command-hook, and triggers only on specific keypresses (e.g. the space bar, a semicolon, an open parens).

As an example, the user would type select and when they press the space key, the buffer would now contain SELECT.

I'm having a hard time writing a test for this with ert. I've tried writing it thus:

(ert-deftest upcase-select ()
  (with-temp-buffer
    (sqlup-mode)
    (insert "select")
    (execute-kbd-macro (kbd "SPC"))
    (should (equal (buffer-string) "SELECT "))))

This test should verify that when I press the space key, the word "select" becomes the word SELECT But the test ends up comparing " " and "SELECT ".

How can I write a test that triggers the behavior I desire?

(and further: is this a terrible idea? what's a better idea?)


texts: How to check if point moved or is on a different line in a buffer since the last user command?

texts:
I would like to make a snippet of code that only executes if the point is on a different line in a particular buffer since the last user command. The only way I could think to do it was using the post-command-hook:
(setq my-prev-line 0)

(defun my-install-move-hook (buf)
  (with-current-buffer buf
    (add-hook 'post-command-hook 'my-move-hook nil t)))

(defun my-move-hook ()
  (when (and my-prev-line (= my-prev-line (line-number-at-pos)))
    (message "The point moved from line number %d to %d" my-prev-line (line-number-at-pos))
    (setq my-prev-line (line-number-at-pos))))

That seems like overkill, since post-command-hook triggers after every command, not just user-invoked commands. Would it be better if the line number was stored during pre-command-hook?


texts: Problem with replace-regexp - Invalid use of \ in replacement

texts:
I want to add extra expressions to some JS code, but taking care of the correct element ID (in the example below, the ID is scatter).

document.getElementById("scatter").height="400"; -->
document.getElementById("scatter").height="400"; document.getElementById("scatter").style="visibility: visible";

My attempt so far has been:

M-x replace-regexp RET
Id("\(\w+\)").height="400"; RET
Id("\0").height="400"; document.getElementById("\0").style="visibility: visible";

Where \(\w+\) grabs the element ID and \0 references it on the replacement string.
Unfortunately replace-regexp is complaining that I'm using \incorrectly.

Could anyone point out what I'm doing wrong?


texts: How to read proper formatted documentation for bookmark+ package?

texts:
I am trying to learn about the bookmark+ package. I installed the package from M-x list-packages and I am using Emacs 25.1.

It looks like a great package, the only difficulty I have so far, is that
the formatting of the documentation for the mode is not directly user friendly. Or maybe I am just used to view documentation in another format? Anyway, it seems to be formatted such that it can be read by a program (presumably a document viewer of some sort). At line 115 of the documentation, it says:

;; If you have library `linkd.el' and Emacs 22 or later, load
;;  `linkd.el' and turn on `linkd-mode' now.  It lets you easily
;;  navigate around the sections of this doc.  Linkd mode will
;;  highlight this Index, as well as the cross-references and section
;;  headings throughout this file.  You can get `linkd.el' here:
;;  http://dto.freeshell.org/notebook/Linkd.html.

However accessing the link http://dto.freeshell.org/notebook/Linkd.html
gives me 500 Internal Server Error.

I wondered if there are other ways to view this documentation with "better" formatting? Perhaps from within Emacs itself?

I have tried:

M-x describe-mode
M-x info
M-x info-emacs-manual
M-x view-emacs-FAQ

but no success so far.

Note:

There is another documentation page (with better formatting):

https://www.emacswiki.org/emacs/BookmarkPlus

but it is a little bit different from the other documentation, so I suspect it is not up-to-date.


texts:
I am using emacs for editing *.tex file. Tex file is controlled under svn.
I recently migrated to new macbook 12" with sub-c.

When I launch emacs from the shell, I do not have any problem in manipulating the tex file. When I launch the emacs clicking the icon in the launch bar, there occur two issue in manipulating the same tex file. They are executing the same emacs binary.

First, when the emacs is launched through icon click, the svn check-in fails. It says
    svn: E155021: This client is too old to work with the working copy at
    '/Users/...' (format 31).
    You need to get a newer Subversion client. For more details, see
     http://subversion.apache.org/faq.html#working-copy-format-change

Second, in shell launched emacs, emacs shows the version number of the tex file in the bottom of its window. When the emacs is launched from the icon clock, i do not see any version number of the tex document.

I think the both issues are rooted at the same reason. I am just wondering if
I could get some clue.


texts: How to use `use-package` when the package and associated feature are named differently?

texts:
What use-package declaration should one use when the name of the package (as present in MELPA or GNU ELPA) and the name of the main feature provided by that package are different? For instance wanderlust provides the feature wl rather than wanderlust. As a consequence, neither of the following will work:

(use-package wl
  :ensure t)

(use-package wanderlust
  :ensure t)


texts: cl-lib isn't loaded the first time an autoloaded function is used from it

texts:
I'm trying to use cl-lib early in my init.el.  The function I'm using (cl-some) is autoloaded, so I expect that don't need an explicit require, yet I get a void-function error if I don't explicitly require.  Sounds like other people have this problem as well: https://stackoverflow.com/a/30848971/245173

;; OK
(require 'cl-lib)
(cl-some #'identity '(nil))

;; void-function the first time, OK subsequently
(cl-some #'identity '(nil))

Why is require necessary if the function is marked for autoloading?  Why does it generate an error and also load the library?

Update: if I (load-library "cl-loaddefs.el"), which is where the autoload for cl-some is, it works correctly the first time.  So it seems like cl-loaddefs isn't being loaded.  Why not?


texts: It looks like the org-git-link.el is now removed from the Org mode repo. Any alternative way to link git file and commit in org-mode?


texts: ledger in org-babel blocks uses incorrect path data in Windows 10

texts:
I am trying to include a ledger data file from an org-babel block. I am using Windows10 and the SciMax emacs distribution.

#+begin_src ledger :cmdline bal :results output :exports results
!include d:/Ledger/RLbook.dat
#+end_src
#+RESULTS  (this is all that appears regardless of the header options)

If I call the file using !include RLbook.dat in the org-block (see below), the block produces the word #+RESULTS but no actual numbers regardless of the header options. Using or excluding ! makes no difference.

My config file call ledgers (ledger . t) as required. The data in the external file produces results if I copy it directly into the org-babel block or if used directly in ledger-mode so I know the data is formatted properly.

I discovered that that although I specify this path in the block d:/Ledger/RLbook.ledger, its being interpreted as c:/Users\Arjay\AppData\Local\Temp\babel-16324iS0\d:/Ledger\RLbook.ledger according to my Messages buffer. I cannot figure out how this extra path data is being added or how to prevent it.

How can I avoid or correct the incorrect path data being added to the path name?

Note: I rebuilt the ledger executable using the instructions from https://gist.github.com/ngleb/944346a67960776371aab74149edf38c. This fixed a problem with ledger not understanding paths when used from the cmd line in a terminal window. It did not fix this problem.


texts: Magit always use current branch to create new branch

texts:
I am currently on master branch and I have to create new branch called test starting from master.

If I run b c in magit buffer, magit will prompt for starting point

  Create branch starting at (default master):

How to prevent this and always use the current branch?


texts: Delete opening and closing tag in web-mode

texts: Is there a way to delete opening and closing html tags in web-mode? I have tried using sgml-delete-tag from within web-mode but can't get it to work properly (I get an error message sgml-lexical-context: Wrong type argument: stringp, nil). Is there a way to delete matching tags in web-mode?


texts: Prevent inserting text at the beginning of a buffer that starts with read-only text

texts:
I'm extending an existing Emacs package and I want to make a part of the buffer not editable (read only).  In fact, I want to make only one line in the middle of the buffer editable and I use the following snippet for achieving that:

(put-text-property (point-min) point-before-editable-text 'read-only t)
;; (put-text-property point-after-editable-text (point-max) 'read-only t)

However, I can still put cursor at the beginning of buffer and insert some text which is not the desired behavior.

How can I prevent insertions at the beginning of the buffer?


texts: Can I remove the indentation in {reftex-toc}?

texts:
I am new user of auctex/reftex and the reftex-toc-function is brilliant.
However, on my small screen a lot of space is wasted when I have a document with only chapters, or even sections. (I put the toc on the left side of my 11-inch screen.)

Parts are indented with one leading space, chapters with three, sections with five.
Is it possible to remove/hide the extraneous indentation when it is not needed?

Examples:

TABLE-OF-CONTENTS on ~/test.tex
SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [l]abels [f]ollow [x]r [?]Help
------------------------------------------------------------------------------
 Part I Part level
    1 Chapter level
      1.1 Section Level

Document with no parts or chapters:

------------------------------------------------------------------------------
      1 This document has only sections
      2 Like this
      3 And this


texts: How to get org-mode to stop prompting me to save org-mode files that contain Babel blocks?

texts:
When I open an org-mode file that has a babel block in emacs-lisp format, afterwards, whenever I run save-some-buffers, I get the File to save in: prompt for the current org-mode file. I get this prompt every time I run save-some-buffers, and each time, I have to Quit out of it.

To try to make the prompt go away I tried accepting it and saving the current file again, which had the effect of overwriting the entire org-mode file with just the first emacs-lisp block.

How do I get org-mode to stop prompting me to save org files that contain Babel blocks?


texts: In Org, how can I mix ordered and unordered lists (numbers and bullets) at the same indentation level?

texts:
I'm new to org mode, and I'm trying to figure out if something like this is possible, and if so, how to do realize it:
* Unordered
    1. Ordered
    2. Ordered
    *  UNORDERED
* Unordered

The key is to have UNORDERED at the same indentation level as the numbered items.


texts: Unusual behavior when overriding `calculate-lisp-indent'

texts:
I've modified calculate-lisp-indent as a better solution to the indentation questions here, here and here. By "modified" I mean I overrode the function with advice. After doing this when I restarted emacs and I tried to indent a lisp form, I'd get the error void-variable calculate-lisp-indent-last-sexp.

Here's where things get interesting. You may be inclined to think that's it's some problem with the code I added to calculate-lisp-indent. But after failing to figuring out what was wrong with the code I added (which by the way didn't even mention calculate-lisp-indent), I tried overriding calculate-lisp-indent with a function that has the exact same body as calculate-lisp-indent. What happened then? I got the same error. Wierd.

Ok, now I started looking at the code for lisp-indent-function and I could not find where the variable calculate-lisp-indent-last-sexp was set. It looked as if it was just unbound.

Check out the beginning of the lisp-indent-function. calculate-lisp-indent-last-sexp was used but not defined.

 (let ((normal-indent (current-column))
        (orig-point (point)))
    (goto-char (1+ (elt state 1)))
    (parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t)
...

A small digression: go to say I'm not sure why parse-partial-sexp is doing here. Based on it's documentation I thought it just returned the list, but I don't see the value it's returning being stored anywhere. Does it have any (undocumented) side-effects?

So my first though was calculate-lisp-indent-last-sexp must be a global variable. But when I tried to describe it with describe-variable I couldn't find it.

Also super interesting. I noticed that after restarting emacs and getting the void variable error, if I re-evaluated the function I wrote to override calculate-lisp-indent then I don't get errors and my changes to calculate-lisp-indent take effect as I would expect.

;; If I re-evaluate this, then the indentation works and I get no errors.
(defun void~calculate-lisp-indent (&optional parse-start)
  "Has same body as `calculate-lisp-indent`."
  ...)

What is going on here?

EDIT: After starting emacs with the advice I performed a few checks.

(foundp #'void~calculate-lisp-indent) ; => t
(advice-member-p #'void~calculate-lisp-indent #'calculate-lisp-indent) ; => a non-nil value

This confirms the advice is a defined function and that it is advising calculate-lisp-indent. I don't understand why re-evaluating it makes a difference.


texts: How to make abbrev expand on symbol, not on word?

texts:
I have something like

(define-abbrev-table 'c++-mode-abbrev-table '(("string" "std::string" nil 0)))

in my .abbrev_defs. However, when I input to_string, the string still gets expanded into std::string results in to_std::string.

How to make abbrev treat the string in definition as a symbol thus expand it only when I input a symbol "string"?


texts: Org file with tag system like gmail, with item under multiple headers synchronised

texts:
How do I get Org-mode do this, similar to gmail's tags.

** Header 1
*** Under header 1
*** Under header 1 and 2
    This content is synchronised
** Header 2
*** Under header 1 and 2
    This content is synchronised

If I edit anything under Under header 1 and 2, then every instance of it should be changed, no matter where I edit it.

Usage case:  Large categorised list of items that sometimes fall under multiple categories.  Need to be able to find the item in any of its categories.


texts: Open new frame when switching between projects in projectile

texts:
Regularly I am working in several projects at the same time, projectile has been great for helping me with all the mess, but now,  I would like to open a different frame per project, i.e., If I switch to the project one I want that in a new frame.

Is that possible? Could you provide with an example snippet for my init.el?


texts: Evil and adding a binding for evil-ex-define-cmd globally for tabbar mode

texts:
I’m using spacemacs:
•  How can I (globally —ie, permanently) bind a new command :tabe to open a new tab in the emacs built-in minor mode TabBar?
•  Right now, :tabnew works. But I want to make :tabe do the same thing as :tabnew
•  I see the following examples:
(when (featurep 'tab-bar)
  (evil-ex-define-cmd "tabnew" 'tab-bar-new-tab)
  (evil-ex-define-cmd "tabn[ext]" 'tab-bar-switch-to-next-tab)
  (evil-ex-define-cmd "tabp[revious]" 'tab-bar-switch-to-prev-tab))

But how do I execute these while in emacs?  Ie, analogous functionality as doing M-x set-global-key


texts:
If I place %^g in my capture template, org will prompt for tags, with completion. But typically, I like to brainstorm on relevant tags, after I finish writing my ideas.

Is there some way to get tag completion by running org-set-tags from within org-capture?

Thanks!


texts:
I am new to Emacs and one thing I really like about it is the "tramp". I use R with ESS and usually "tramp" to my work computer from home. We also have an HPC server and I am wondering whether it is possible to open a "tramp" to the HPC server, call an interactive session using "qrsh" and open an ESS based R process. I've done this just by "tramping" to a terminal then called "qrsh" and ran an R process inside the terminal. I could send commands from my script to the shell-based R process but obviously this is not the same as having ESS's inferior R mode.

Thanks.

Edit:
I've tried

(add-to-list 'tramp-methods
  '("qrsh"
    (tramp-login-program        "qrsh")
    (tramp-login-args           (("-V -cwd -l inter -l short"))) ; other options here?
    ;; Local $SHELL could be a nasty one, like zsh or fish.  Let's override it.
    (tramp-login-env            (("SHELL") ("/bin/sh")))
    (tramp-remote-shell         "/bin/sh")
    (tramp-remote-shell-args    ("-c"))
    (tramp-connection-timeout   10)))

Then after M-x R RET /ssh:myserver|qrsh:myserver:TempDir RET


texts: Check if buffername is equal to file name

texts:
I'm trying to autoexport a file from orgmode to html, so I decided to make a function to check the major mode of the buffer and check if the buffer has open the file that I want to export but when I try it the function export all the orgmode files and not the one that I want.

Here is the code:

(defun org-mode-export-hook()
"Auto export html"
(when (eq major-mode 'org-mode)
    (when (eq buffer-file-name "/home/rafa/org/to-read.org")
        (org-twbs-export-to-html t))))

Can anyone tell me what I'm doing wrong??


texts: How can I refresh the ELPA directory content without having to select and re-download the packages manually? (for slowed ver. 25.1 in Windows 10)

texts:
Hi fellow Emacs users,

I'm experience very slower performance of 25.1 but a startup with -Q indicated the problem is probably caused by my old packages.
(Similar scenario: https://www.reddit.com/r/emacs/comments/55ork0/is_emacs_251_noticeably_slower_than_245_on_windows/)

Removing all the old byte-compiled package files in ELPA (and perhaps also in other folders? please suggest) will be necessary. But I'm paranoid as to keeping some older contents suited version 24 will also affect version 25. So I am planning to refresh every packages to their latest versions, and remove those obsolete packages with obviously suspended maintenance.

I foresee that I need to remove the content of the whole ELPA folder manually; but for re-downloading the packages to the ELPA folder, I don't want to compare a previously saved list visually and add them one by one manually in package-list-packages.

Is there a smarter way?

Thanks for your help.


texts: Built-in function to get column at point

texts:
Is there a built-in function that does this:

(defun mk-column-at (point)
  "Return column number at POINT."
  (save-excursion
    (goto-char point)
    (current-column)))


texts:
On a Linux machine  I symlink some directories into my home directory like this:

/home/mrdarcy:
total used in directory 231 available 520120
drwxrwxr-x  3     4k 04-30 18:16 bin
drwxr-xr-x  2     4k 2017-08-23  Desktop
lrwxrwxrwx  1     30 2017-10-10  devel -> /working/mrdarcy/devel
.
.
.

(because /working is the mount point of a much bigger disk).

When I view my home director in Dired and I am on the devel line I would like to open the symlinked directory. However the command I know of, dired-find-file, opens it as /home/mrdarcy/devel.

How can I follow the symlink with a Dired command and open /working/mrdarcy/devel?


texts: How to change the color of numbers for a theme?

texts:
Is there a way to set the color of numbers differently to that of regular text?

for example, numbers such as: 1, 2F, 2.0f, 0x1234.

Can this be changed by a theme author?
If not, how can this be modified?


texts: Emacs Mode to edit template toolkit files

texts:
Is there a mode to edit template toolkit files ?
Web-Mode works decently, but maybe some modes can be combined to proved some specific Perl-editing-Funcitonality?


texts: Enable Linum Mode for all files (with extension) but not other buffers?

texts:
In my init.el file I have the following line: (global-linum-mode 1).  I want linum-mode enabled for every file, but not for other buffers.  I.e. Is there a way to enable linum mode globally for all buffers with an extension?

Frequently my buffer list looks like

file.js  js2-mode
init.el   Emacs-Lisp
ansi-term Term:

In this case I would like to have it enabled for everything but ansi-term. Is this possible?

Furthermode, just for ansi term I tried the following:

(add-hook 'term-mode-hook (lambda () (linum-mode -1)))

But even that did not work.  If someone could tell me why that would be great but enabling it just for files would be ideal.

Thanks


texts: Project management in projectile or other, like Sublime Text's projects

texts:
Ever since I first started using Emacs (Spacemacs) a few months ago I've been trying to set up a sane multi-project workflow. I got the single project workflow going by having Emacs start up into what I had open last, all windows, all buffers and all cursor positions (using dotspacemacs-auto-resume-layouts t)

While that's fine for single projects, it doesn't scale at all.

What I'm after is similar to how Sublime Text handles projects, ideally with a .projectile file that keeps all the project's settings. That way a folder is portable, can be zipped up and passed on.

So far my setup is pretty poor with projectile. All it does is open a frame with a dired buffer and nothing else. Not all that useful. With Sublime Text I have to ship the project definition file with the rest of the folders. Usually that works by placing the project file in the parent folder along with a readme file and zip it from there.

Since Emacs is a wee bit older than Sublime, I was hoping there would be a simpler way (once it's set up) that makes this whole thing easier.

The thing is, I just don't know where to begin there. It probably sounds quite broad so I'll just list the specifics.

Have a dotfile in a folder that stores:

Frame layout (Window position & size)
Buffer content for each window

The main issue here is portability. Bookmark+ like mentioned before seems to only deal in absolute paths. For portability that creates problems, especially since we have projectile-project-root available to get the project path. So a relative solution must be possible somehow.

Basically everything that the auto resume does, but for each project. In essence I want to launch Emacs and just see the welcome screen, pick a project and it comes up like the last time I've left it.

I'm using Emacs-plus (homebrew) 25/26 with Spacemacs on Desktop not Terminal (just in case that's relevant). My main modes are markdown-mode, org-mode, image-mode and later on probably latex-mode (haven't checked yet on LaTex modes for Emacs).


texts:
Exploring far-out init files, I found this here:

(defmacro section (name &rest a) `(progn ,@a))
(put 'section 'lisp-indent-function 'defun)

then it's used AFAICT as a sort of wrapper, not sure of the genius behind all this. Thought it would be a good thing to know. Can someone explain what it all means?


texts:
I want to fill (wrap) long lines at n characters, ensuring that each new line ends with "///". (That is the "continuation character" for long lines in Stata code.

So that something like this

This is a long line. This is a long line. This is a long line. This is a long line. This is a long line. This is a long line.

would be broken up into something like this

This is a long line. This is a long line. This is a long line. This ///
  is a long line. This is a long line. This is a long line.

(where the first line, along with the /// is no more than n characters.

I see info about prefixes in the fill section of the manual, but nothing about suffixes.

Thanks!


texts:
Sometimes I prefer to do some work offline. I can time it and write it down and avoid starting up my computer.

I like to use a table and org-update-all-dblocks to calculate my hours for the day. It's very convenient for me, because I might spend odd numbers of minutes throughout the day doing work for a client.

If I want to quickly add my offline hours and update the table, does org-mode already have a function for this? I know that I can org-clock-in and org-clock-out to generate a clock, and then manually retype it and use org-update-all-dblocks to recalculate, but I would ideally like a single function I can call that will ask me for how many minutes I want to input. It should probably just use the current time and date as the start, even though that would seemingly conflict with work I start doing after adding the offline hours.

It would be even better if org-mode had a concept of offline hours that understood I might know the date but I probably didn't record the time of day, and so the time of day could be left out, but still calculated in a clock table.

If I have to write some quick and dirty elisp, what functions would be of use to me apart from the above? I think the pieces I'm missing is something to grab the most recent clock, something to add minutes to it, and something to request a number of minutes.


texts:
I have some defcustom variables that are for keymaps. Is there a way to set the :type in a defcustom to indicate it should be a keymap?
Is the right way to do it like this?
:type '(restricted-sexp :match-alternatives keymapp)


texts: magit equivalent of gitk's "Diff this -> selected"

texts:
gitk has a feature where you select one commit, then right-click another and can choose to either "Diff this -> selected" or "Diff selected -> this".

Is something like this possible in magit-log? Meaning, place point on a commit, press something, place point on another commit, and get a diff between the two commits?


texts: Can't disable semantic wisent-python-default-setup on python-mode-hook

texts:
Here is the error when semantic by default add wisent-python-default-setup into hook python-mode-hook.
It's shown in minibuffer.

  Makeing python-shell-interpreter-args local to Python Internal[ org-src-fontification:python-mode] while let-bound!

It happens when I open Org-buffer with Babel Python code block, and python source code file.

I found relative issue here:

https://github.com/jorgenschaefer/elpy/issues/531

Then I try to remove this from hook by the following code:

(remove-hook 'python-mode-hook 'wisent-python-default-setup)

But this does not work, after Emacs finished start, I check out python-mode-hook, it's still over there.

I guess maybe semantic is enabled after my upper "removing it from hook". But I don't know when and where. (Maybe someone can tell me how to debug it)


texts: magit-diff and magit-status not opening in fullframe in some contexts

texts:
I would like magit-diff and magit-status to always take up the entire frame. I am trying to do this using the fullframe package, and have configured things according to the documentation using:

(fullframe magit-status magit-mode-quit-window)
(fullframe magit-diff magit-mode-quit-window)

This configuration works if I use M-x magit-status/magit-diff. But if magit-status gets called from certain contexts, say if I access magit-status from the helm-projectile menu (M-g for me), or if I access magit-diff from magit-status by hitting return on e.g., staged/unstaged changes, neither is in fullframe - and this is a problem, because this is how I usually access these modes...Any suggestions as to how to configure things so that the specified commands trigger fullframe regardless of how they are called? Or is it the case that different functions are actually being called when magit-status and magit-diff are called in different context? I am not sure what's going on exactly...Thank you!


texts: replace-buffer-in-windows issues in switching from emacs 24.5 to emacs 25.2

texts:
I installed Emacs 25.2 on a new system and cannot get the desired behavior with killing buffers when an Emacs frame is split into multiple windows.
For example, I have C-x 3 bound to a variation of split-window-horizontally that opens a second buffer different from the first in the newly created window. When I kill this second buffer in the new window, I have the same buffer displayed in both the windows. On Emacs 24.5, I get a third buffer displayed in the new window which is quite convenient.
How can I get the same behavior in Emacs 25.2?


texts: Emacs lisp function to count the difference between two times

texts:
I would like to write an Emacs lisp function, that I can bind to a key shortcut. It will read in the two previous time entries in the format HHMM from the buffer and spit out the difference between them in the format 0.75, that is 45 minutes.

This is the format it should operate with.

1400 Enable ftp access for Sarah
1430
.5

find the previous instance of HHMM in this buffer, occurs at the beginning of a line, and then find the one before that
determine the difference between the two times
output in hours with decimal fractions instead of minutes

Pseudo code

$end-time      = (search back from pointer for previous instance of HHMM)
$begin-time    = (search for second previous instance of HHMM)

$end-hour      = $end-time[0,1]
$end-minute    = $end-time[2,3]

$begin-hour    = $begin-time[0,1]
$begin-minute  = $begin-time[2,3]

$total-hours   = $end-hour - $begin-hour
$total-minutes = $end-minutes - $begin-minutes

return $total-hours + ($total-minutes * 0.01666666667)


texts: How can I use the console's menu-bar while running under xwindows?

texts:
I like the variable font size feature that emacs has under xwindows.

But, I dislike the menus under xwindows.  They are generated by GTK or something and they stick out like a sore thumb.

Can I use emacs's rendering engine instead of GTK to draw the menus when I'm running under xwindows?  Would that allow me to customize their appearance the same way I'd customize the appearance of the modeline?

If I build emacs with configure --with-x --with-x-toolkit=no, I get an emacs which looks like this:

Unfortunately, these menus are worse and now my emacs no longer supports the xwidgets stuff (not that I've played with it anyway).


texts: `(setq max-mini-window-height 1)` splits windows randomly

texts:
I have observed that using (setq max-mini-window-height 1) splits windows randomly. I was wondering what may be the main cause of this?

On the example file, when the cursor comes to beginning of less and types | it splits the window.
example.sh
echo "alper" | less

I can try to do further debugging if requested.


texts: I would like to be able to open .eml files with mu4e and read them like regular mails. I've seen a solution for Gnus, but I would like to stay with mu4e. Any ideas?


texts: Delete file (if it exists) before saving

texts:
My problem is that I can create, but not overwrite existing files.  This is probably due to a bug in MegaFuse.  Because of this, when I finish editing a file I must first save it under a different name, and then replace the original by hand.  Of course, this also affects emacs' auto-save and backup, because it only functions well on the first attempt.

I'd be happy enough with a function/command that could simply do:

delete-file <current-buffer-name>
write-file <current-buffer-name>

(I'm still an early beginner on emacs matters, and I still don't understand lisp very well.)

Btw, do you know any keybinding I could use for this command?


texts: Function that gets a subdirectory of user-emacs-directory

texts:
I remember reading about this function (it's part of Emacs) somewhere, but I can't for the life of me remember what it's called.

It takes a single argument arg (not sure if there's any more optional args)

By default it looks for (expand-file-name arg "~/") and returns the path if it exists.
If not, it looks for (expand-file-name arg user-emacs-directory) and returns the path if it exists.
Otherwise, it creates the subdirectory in user-emacs-directory and returns the path.


texts: How to cross reference input method in docstring?

texts:
I'd like to cross reference an input method from a minor mode docstring:

(define-derived-mode xxx
  ...
  "Super `xxx' derived mode.

  Cool to use with input method `my-magic-input-method'.")

Now my-magic-input-method is not linked in *Help* window. Is there a way to inform Emacs about input method links like there are methods to inform it about variables, functions and symbols?


texts:
I'm following the instruction at
http://www.emacswiki.org/emacs/AllOut#toc3
to have the allout mode fontify its headers (enclosed below).

It works but the existing major mode's fontifying effort would be gone. Is it possible to have them both?

(defvar rf-allout-font-lock-keywords
  '(;;
    ;; Highlight headings according to the level.
    (eval . (list (concat "^\\(" outline-regexp "\\).+")
        0 '(or (cdr (assq (outline-depth)
                  '((1 . font-lock-function-name-face)
                    (2 . font-lock-variable-name-face)
                    (3 . font-lock-keyword-face)
                    (4 . font-lock-builtin-face)
                    (5 . font-lock-comment-face)
                    (6 . font-lock-constant-face)
                    (7 . font-lock-type-face)
                    (8 . font-lock-string-face))))
               font-lock-warning-face)
        nil t)))
  "Additional expressions to highlight in Outline mode.")

;; add font-lock to allout mode
(defun rf-allout-font-lock-hook ()
  (set (make-local-variable 'font-lock-defaults)
       '(rf-allout-font-lock-keywords t nil nil outline-back-to-current-heading)))

(add-hook 'outline-mode-hook 'rf-allout-font-lock-hook)


texts:
I'm updating my Ubuntu distro to LTS 16.04 release.

I followed the instructions given at irony mode in github and company irony in github in order to get autocompletion features in Emacs. For both packages, I have put the given configuration into .emacs file located in my home directory.

Now when I open a C++ file, the Emacs status bar indicates C++/l Irony Abbrev message. So, deduce that Emacs has understood something related to ironic mode. However, until now I cannot appreciate some autocompletion behavior.

So, after doing some searches without getting a solution, I would want to ask to this forum for some clue or help. What should I revise? Is there some specific step for Ubuntu 16.04?

EDIT: this is the content of my init.el file in the .emacs.d directory:

(when (>= emacs-major-version 24)
  (require 'package)
  (add-to-list
   'package-archives
   '("melpa" . "http://melpa.org/packages/")
   t)
  (package-initialize))

(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 (manoj-dark))))
(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.
 )

(add-hook 'c++-mode-hook 'irony-mode)
(add-hook 'c-mode-hook 'irony-mode)
(add-hook 'objc-mode-hook 'irony-mode)

;; replace the `completion-at-point' and `complete-symbol' bindings in
;; irony-mode's buffers by irony-mode's function
(defun my-irony-mode-hook ()
  (define-key irony-mode-map [remap completion-at-point]
    'irony-completion-at-point-async)
  (define-key irony-mode-map [remap complete-symbol]
    'irony-completion-at-point-async))
(add-hook 'irony-mode-hook 'my-irony-mode-hook)
(add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)

The directory .emacs.d contains a subdir called elpa which contains another subdir irony-20160628.1329 where I suppose is installed irony mode.


texts: Smart Tab : indenting with C-u  does not work (beginning of a line)

texts:
(I haven't find any answer in previous topics)

I am using Smart Tab globally, i.e. I have put the following code in my .emacs :

(require 'smart-tab)
(global-smart-tab-mode 1)

I am writing a program in Fortran, and I often need to indent some lines, which, according to smart-tab documentation, is done either by prefixing the smart-tab command (i.e. <tab>) by C-u or by selecting the region to be indented before hitting <tab>.

After some research, I still don't understand why only the "selecting a region" method works for me : to indent just one line, I need to have it selected, but C-u <tab> does not work, and always gives to following message (which I don't understand) :

Symbol's function definition is void: cl-case

Being able to indent any line (and just one line) by using <tab> in a simple command would solve my problem (while keeping smart-tab).


texts:
I have this LaTeX code:

\begin{enumerate}[a]

\affiliation{...}

\affiliation{...}

\affiliation{...}

 ...

\affiliation{...}

\end{enumerate}

and, using a script written in Emacs Lisp, I want to obtain:

\affiliation[a]{...}

\affiliation[b]{...}

...

\affiliation[n]{...}

I started from the following code thinking I could change it 'quite easily' in order to resolve my problem, but I failed.

Here it is my code:

(perform-replace "\\\\affiliation{"
     `((lambda (data count)
                   (concat "\\\\affiliation{"(number-to-string (+ 1 count))"}"))) nil t nil 1 nil a z)

How can I modify number-to-string to obtain lowercase letters instead of numbers?

A note: \begin{enumerate}[a] could be absent, so first occurence of \affiliation{...} is replaced using the following code:

(perform-replace "\\\\begin{enumerate}\\[a\\]\n\n\\\\affiliation{" "\n\n\\\\affiliation[a]{" t t nil 1 nil a z)


texts: Validate internal fuzzy links in org-mode

texts:
Is there a function that will validate internal fuzzy links in org-mode? I would like to see which links resolve to headers (fontified in blue) and which ones are broke (fontified in red).

John Kitchin had a good solution for external links:

(org-link-set-parameters
 "file"
 :face (lambda (path) (if (file-exists-p path) 'org-link 'org-warning)))

and I found this code, as part of org-lint:

  (defun org-lint-invalid-fuzzy-link (ast)
    (let ((info (list :parse-tree ast)))
      (org-element-map ast 'link
        (lambda (link)
          (and (equal (org-element-property :type link) "fuzzy")
               (not (ignore-errors (org-export-resolve-fuzzy-link link info)))
               (list (org-element-property :begin link)
                     (format "Unknown fuzzy location \"%s\""
                             (let ((path (org-element-property :path link)))
                               (if (string-prefix-p "*" path)
                                   (substring path 1)
                                 path)))))))))

Is there is a way to marry these together?


texts: Passing parameter to a function in init-file

texts:
I'm trying to create a .emacs file that works on multiple platforms. Therefore, I declare a variable with a path for each platform

(defvar macosx-p (string-match "darwin" (symbol-name system-type)))
(defvar gnulinux-p (string-match "linux" (symbol-name system-type)))
(defvar mswindows-p (string-match "windows" (symbol-name system-type)))

(defconst macosx-ps "/Users/xxx/")
(defconst gnulinux-ps "/home/xxx")
(defconst mswindows-ps "D:/xxx")

How can I pass one of the -ps variables to a function like this?

(if macosx-p
   (progn
    (setq org-capture-templates
     '(("t" "TODO" entry (file+headline (concat macosx-ps "file.org") "Inbox")
          "* TODO %?")))))

(if gnulinux-p
  (progn
   (setq org-agenda-files (quote
   ((concat gnulinux-ps "file.org")
    (concat gnulinux-ps "others/"))))))

I want macosx-ps to output my path string.


texts: How to use a fixed desktop save directory name with desktop-save-mode?

texts:
I would like to use a standard desktop save file when using Emacs as a server (with Emacsclient) and use no desktop save file (or optionally, another desktop save file) when running a regular Emacs instance (no server-start command).

Is it possible to use a fixed desktop save directory name with desktop-save-mode?

If I use:

(desktop-save-mode 1)

I have no direct control over where the desktop is saved (though, I think it is saved in ~/.emacs.d/.emacs.desktop).

I tried to add the following to my Emacs init file:

(require 'desktop)
(defvar my-desktop-dir "~/emacs-server")
(when (file-exists-p (desktop-full-file-name my-desktop-dir))
  (desktop-read my-desktop-dir))
(add-hook 'kill-emacs-hook (lambda () (desktop-save my-desktop-dir))))

while this seems to work, I am not sure if desktop auto save will be enabled.. From the manual :

  When desktop-save-mode is active and the desktop file exists, Emacs
  auto-saves it every desktop-auto-save-timeout seconds, if that is
  non-nil and non-zero.

so in order to make desktop-save-mode active, I have to run (desktop-save-mode 1) in my init file. The problem is that this command then will revert to the desktop stored in ~/.emacs.d, which is not desired.


texts:
In C there is the magic variable __func__ that holds the current function name. In Bash, there is an array FUNCNAME holding the names of all functions in the calling stack !!!

Is there a similar thing in Emacs Lisp? Or any simple way for a function to have access to its name?

I have not found any answer in the Emacs Lisp manual (chapter 12 on Functions or index of variables and functions and ..)


texts: Render non-ascii chars correctly in Info buffers?

texts:
I'm reading the Emacs manual in Info-mode. Some non-ascii characters render as octal escape sequences rather than glyphs. For example, node 23.2 Minor Modes contains the following text:

  Electric Quote mode automatically converts quotation marks.  For
  example, it requotes text typed `like this' to text ‘like
  this’.

When I view it in an info buffer, I see:

  Electric Quote mode automatically converts quotation marks.  For
  example, it requotes text typed `like this' to text \342\200\230like
  this\342\200\231.

If I select this text and write the region to a file, I can open that file and Emacs renders it correctly.

I'm running Emacs in a gui, but I've repro'd everything above in the terminal as well, and both with and without my init file.

What's causing this behavior, and how can I fix it so info buffers render correctly?


texts: Orgmode Latex Preview: Change Font Color

texts:
In Orgmode we can use C-c C-x C-l to preview Latex equations in the text.

I am using a theme that makes it hard to read the equation in the default font color, and I want to avoid changing the scale to make it more readable.

Question: How can I change the font color used when previewing latex equations within orgmode with C-c C-x C-l?

Related Question: Is there a preamble that is used to generate the preview equations with C-c C-x C-l? If so, how can I change it?

Thank you for helping!


texts: How to remove subdirectories inserted into the dired buffer with i?

texts: Pressing i on a subdirectory in the dired mode inserts that directory in the buffer. How can I remove it from the buffer?


texts: How do I export some of the subheadings in a subtree marked as :noexport:?

texts:
I would like to be able to have an org-mode file that looks like the following:

* Some Heading     :ignore:noexport:
** Not exported
   Some stuff.
** Other not exported heading
   More stuff.
** Exported        :export:
   Other stuff.

What should get produced when exporting would look like:

Exported
--------

Other Stuff.

The :ignore: tag is used in conjunction with the ox-extra package's ignore-headlines functionality -- see this for details.

It seems that the org-mode file above won't currently export -- is there a workaround that would allow this to work?  It seems like the key here would be to make org-mode work so that the presence of an :export: tag removes any inherited :noexport: tag, and vice versa -- the presence of a :noexport: tag should remove an inherited :export: tag for the headline.


texts: Let-bind diplayed windows and their size/posizion

texts:
Can I let-bind diplayed windows and their size/posizion? Is there a variable that stores these infos?
I need to run a script that will change the diplayed windows, opening some help temp buffers. At the end of the script I'd like to restore the starting layout (displayed windows and their size/posizion).
Edit. Finally I found that current-frame-configuration/set-frame-configuration is what I need,


texts: Anyway to have an org-mode doc open in 1 pane and a live buffer export in a second pane?


texts: Is there org-mode gantt view feature/package?

texts:
Is there some sort of gantt chart view package/feature for org-mode?

I want to view my headings in the gantt chart (rather then as we see it in agenda), and at least interactively modify those schedule by following operations:

change the start or end date.
shift the time range by not changing its length.


texts: Expand/shrink region after double-clicking mouse-1

texts: How can I change the default double-mouse-1 word selection behavior so that I can move the point around right afterwards to extend/shrink the region? By default, if I forward/backward-char after selecting the word by double-mouse-1, it moves the point, but the mark disappears, so nothing is selected.


texts: How can I disable semicolon electric behaviour without impacting the other electric chars in CC-mode?

texts:
In CC-mode when the electric behavior of characters is enabled, typing the semicolon character triggers the c-electric-semi&comma command.  That inserts the semicolon, terminates the line, moves point to next line and indents it.
Question:
How can I disable this electric behaviour of the semicolon temporarily, while retaining the electric behaviour of the other characters?
For example, I'd do that when I want to write several lines with comments at the end of the line, so I'd be able to type the semicolon and stay on the same line so I can write the C or C++ style comment at the end of the line.
I know how to disable RET electric behaviour (by removing it from the electric-indent-char list).  But ?; is not part of that list when the semicolon is exhibiting electric behaviour.


texts:
Sometimes it is convenient to set a manual column width when creating a table in org-mode.  This makes it so that columns do not have to grow to the size of their longest entry.  When an entry in and org-mode table is longer than the column it is found in, the entry gets visually truncated with a => symbol at the end.

I know that I can do C-c ` to use org-table-edit-field, but this requires pressing C-c C-c to close the preview window and get back to the org-mode buffer.  Calling the same command with a prefix argument C-u C-c ` makes the full field visible so that it can be edited in place, but it is still tedious if I want to quickly preview 5-10 fields in quick succession.

LibreOffice Calc has a preview field at the top of a spreadsheet (so does MS Excel) which shows the value of the currently selected field:

Is it possible to get a similar preview when editing an org-mode table?  The minibuffer seems like one good place for it, although it might have the side effect of filling up the *Messages* buffer quickly. A dedicated mini window at the top or bottom of the buffer would also work.


texts: How can I set and jump to file-specific Bookmark+ bookmarks

texts:
I am trying to use Bookmark+ because I would like the ability to create bookmarks with the same name that jump to locations in different files.
E.g. I have files foo and bar open in emacs. I would like to create bookmarks named a, b and c that map to three different locations in foo. I would also like to create three additional bookmarks also named a, b and c, and these should allow me to jump to different locations in bar.
Then, if the file foo is loaded in the current buffer I would like to jump to bookmark a in foo. If I then switch the current buffer to file bar and jump to bookmark a, I would like to be directed to the location of a within file bar.
I have read the Bookmark+ docs and believe this to be possible. I have tried creating bookmarks with C-x p m and C-u C-x p m, and jumping to them using C-x j f and C-x j , , but often I end up being directed to the wrong file.
Which commands should I be using to set and navigate to these types of file-specific bookmark?
--
Follow up
Thanks @Drew for this clear explanation, I think I understand now. I have recently tried to play with icicles but I think the install didn't go quite right and I got errors. Maybe I'll have another go.
Why do I want to do this? Mostly idle curiosity I have to admit. I really like the idea of not having to worry about duplicating bookmark names, and as I understand it this is supported and works if I use the bookmark-list display. The reason for trying to use the jump commands is to save keystrokes. I can navigate to a vanilla bookmark in three keystrokes: one bound to a command to list bookmarks, one character to filter to a specific bookmark, enter and I'm there. To do the same using bookmark+ I'm currently doing: one key bound to C-x p ,, / to start search, a filter character, Enter, then multiple Down key to get to the bookmark I want, then enter. Four plus at least three or four cursor downs (I'm working from memory here).


texts: Symbol Highlight Transient State select all words

texts:
I am using Spacemacs. I want to move between variables easily and while using #spacemacs/enter-ahs-backward function. I want to select the even word near of some special characters like $!:<>
Currently
If I use # spacemacs/enter-ahs-backward or *spacemacs/enter-ahs-forward, it does not ignore some special characters, so that reason does not select all words.

Expected

Select all words

Additional info for humans

Text which I use

    - Works
      foo-bar;
      (foo-bar)
      [foo-bar]
      #foo-bar
      ,foo-bar

    - Does not work
      <foo-bar>
      foo-bar:

Using same functions in emacs-lisp vs sh-mode gives different results!!!

Additional info for search engines

This shortcuts uses auto-highlight-symbol-mode
Spacemacs call this feature symbol highlight transient state


texts: In projectile.el's source code, how does switch-project-action "know" which project to switch to?

texts:
In this function definition snippet, a call to switch-project-action is done without any arguments. How does it switch to the correct project?

(defun projectile-switch-project-by-name (project-to-switch &optional arg)
  "Switch to project by project name PROJECT-TO-SWITCH.
Invokes the command referenced by `projectile-switch-project-action' on switch.
With a prefix ARG invokes `projectile-commander' instead of
`projectile-switch-project-action.'"
  (let* ((default-directory project-to-switch)
         (switch-project-action (if arg
                                    'projectile-commander
                                  projectile-switch-project-action)))
    (run-hooks 'projectile-before-switch-project-hook)
    (funcall switch-project-action)
    (run-hooks 'projectile-after-switch-project-hook)))


texts: Make tabs be visually 4 spaces long but 1 column only

texts:
I indent my code with tabs and I want my tabs to be visually 4 spaces long but to be 1 column only.
Currently with my configurations my tabs are 4 spaces long but also 4 columns long and I can't find anywhere how I can make it 1 column long only, but I know it is possible because I've used a configurations on another computer that did that.
Unfortunately I can't get back to that computer anymore.
If needed here is my .emacs:
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(defvaralias 'c-basic-offset 'tab-width)


texts: Summing Properties Across Subheadings (Org-Mode)

texts:
Suppose our cursor/point it located on the first line of Parent Task in the following:

* Parent Task
:PROPERTIES:
:END:

** Sub-Task A
:PROPERTIES:
:TALLY: 2
:END:

** Sub-Task B
:PROPERTIES:
:TALLY: 8
:END:

Question: Is there a way to write a function which (i) sums the :TALLY sub-properties from Sub-Task A and Sub-Task B and (ii) inserts them into the :TALLY_SUM property of Parent Task?

I know that for part (ii) we can use the org-mode property API function (org-entry-put "TALLY_SUM" <sum>).


texts: Spacemacs terminal emulator share history with zsh

texts:
In plain vanilla emacs, I can M-x term RET RET. This starts zsh. And it 'shares' history with my non-emacs terminals.

So, I can ESC / and search for commands, etc.

How do I achieve that for spacemacs?


texts: How to display current task and running clock in modeline

texts:
I started using org-mode's clocking commands for tracking how I spend time at work. While the clock is running, the current task is shown in the mode line, along with the title of the task, but only when I am in the agenda.

Can I somehow display this information in the modeline even if I am not visiting an agenda buffer?


texts: Why is the desktop version of emacs so slow in handling large text?

texts:
I have a large text file that's over 8 MB. I can't really open it in desktop Emacs since it takes at least 30 seconds just to open the file via find-file, and it takes like 10 seconds for the screen to refresh appropriately when scrolling just one line or so. I tried setting the mode to fundamental, copying the whole text from the large file I mentioned that's opened in Sublime Text 2, and pasting to the emacs' buffer, and the text didn't show in 30 seconds so I killed the whole process. In Sublime Text 2, on the other hand, it just took 2 seconds to paste the whole text to another text file.

This doesn't happen in the terminal version of Emacs. Nor in other similar text editors like Atom or Sublime Text 2.

My Emacs: 24.5 (9.0) for OS X desktop.


texts: Why do some faces not work with font lock mode expressions?

texts:
I'm trying to learn about font locking in my own custom major modes. I can get things working fine for the most part, keywords highlighted, regexp-opt matching strings, using capture groups within a regexp to highlight just the capture group, etc.
But I've noticed that some of the faces that I have tried (such as dired-directory) do not work in font lock expressions, even though other faces such as font-lock-keyword-face work fine in the same slot.
Reading the manual says that face variables should be faces that have a value property that evaluates to the face name. Sure enough, when I eval font-lock-keyword-face, the value is the same as the face name. But when I eval dired-directory face, its value is nil.
So it looks like the value nil is the proximal cause of the problem, and the answer to my question (kind of). But it's not really a good answer.
(1) Why doesn't the dired-directory face that I see listed with list-faces-display have a value the same as the face name?
(2) How can any mode use the face, if the font lock implementation requires that the face name symbol evaluates to the face name, when dired-directory face does not?
Here is a link in SX that touches on the same subject, but it mentions that the solution might be obsolete.
Update
Here is my code line that motivated the problem.
 ( ,(regexp-opt ct-mode-nset-keywords ) . font-lock-keyword-face)

(1) Using font-lock-keyword-face (with no quote) works. (2) Using dired-directory (with no quote) fails. (3) Thanks to @theldoria, using 'dired-directory (with quote) works.
Here is what the manual says:

22.6.7 Faces for Font Lock
Font Lock mode can highlight using any face, but Emacs defines several faces specifically for Font Lock to use to highlight text. These Font Lock faces are listed below. They can also be used by major modes for syntactic highlighting outside of Font Lock mode (see Major Mode Conventions).
Each of these symbols is both a face name, and a variable whose default value is the symbol itself. Thus, the default value of font-lock-comment-face is font-lock-comment-face.

Thank you to everyone who responded -- I have a working syntax to use going forward. And sorry for the confusion using dired-directory as my example - it is both a face and a separate variable holding a directory (or nil). It would have been better for me to use dired-flagged or some other face from list-faces-display, which trigger a void variable error instead of nil.
But now I'm wondering if the face-symbol-with-variable-value model is somehow old or obsolete, even if it is in the manual. Font lock apparently requires that variable value one way or another (eg with a 'quoted-face-name), but other faces in the list-faces-display do not have that value property (eg. dired-flagged, avy-lead-face, etc).


texts:
I'm struggling with teaching SMIE how to handle if-elseif-else constructs correctly.
In the following test file the indentation of the last line, i.e. xoxox;, is wrong.
I suppose something's wrong with my definition of elseif in the grammar. But what is it? How can I fix it?
if a > 5 then
    foo;
    bar;
else
    foo;
    bar;
end;

xoxox; // correct indentation

if a > 5 then
    foo;
    bar;
elseif a > 5 then
    foo;
    bar;
else
    foo;
    bar;
end;

    xoxox; // wrong indentation

This is the code:
(require 'smie)

(setq foobar-grammar
  (smie-prec2->grammar
   (smie-bnf->prec2
    `((insts (insts ";" insts)
             (inst))
      (inst (if))
      (exp)
      (if ("if" exp "then" else "end"))
      (else (insts)
            (insts "else" insts)
            (insts "elseif" exp "then" else)))
    '((assoc ";")
      (assoc "then" "end")
      ))))

(defun foobar-rules (kind token)
  (message "rule: (%s . %s) at point %d" kind token (point))
  (pcase (cons kind token)

    (`(:before . "then") (smie-rule-parent 0))

    (`(:before . "else") (smie-rule-parent 0))
    (`(:after . "else") (smie-rule-parent 4))

    (`(:before . "elseif") (smie-rule-parent 0))
    (`(:after . "elseif") (smie-rule-parent 4))

    (`(:before . "end") (smie-rule-parent 0))
    ))

(define-derived-mode foobar-mode prog-mode "foobar"
  :syntax-table nil
  (modify-syntax-entry ?/ ". 124")
  (modify-syntax-entry ?* ". 23b")
  (modify-syntax-entry ?\n ">")
  (setq comment-start "//")
  (smie-setup foobar-grammar #'foobar-rules)
  (font-lock-add-keywords
   nil
   `((,(regexp-opt '("if" "then" "elseif" "else" "end")) . font-lock-keyword-face)))
  (font-lock-mode)
  (font-lock-ensure (point-min) (point-max)))


texts:
The minor mode global-hl-line highlights the current line "permanently" (until it is disabled).

Instead, I would prefer a command which highlights the current line for, say, one second.

Has anybody done this?


texts: Why does bmkp-desktop-jump change colour scheme?

texts:
I just realised (after playing with different colour themes) that bmkp-desktop-jump from Bookmarks+ changes the colour theme to the one selected before - this is nice, but can cause unwanted effects.

Hence, these questions:

Where is the colour theme stored? I could not find it in the bookmarks file, and it's also not in the .emacs.desktop file.
How can I disable this?
Can I disable this for certain bookmarks?


texts: How to change the current working directory?

texts:
how to change the current working directory of emacs?

set default-directory doesn't not affect the emacs process's current working directory, which can be verified via lsof -p pid.


texts: Connecting to Slack channels with Jabber

texts: I can connect with Slack through jabber and chat with individual users, but I can't join channels. There are some instructions here, but I don't know which jabber commands to use. I've tried jabber-muc-join and jabber-groupchat-join, but neither of those seem to work. I use conference.name.xmpp.slack.com for the server name.


texts: What linux terminal app is compatible with emacs keybindings?

texts:
I am using terminal Emacs (emacs -nw). Gnome terminal doesn't behave well with it (key bindings break), and KDE's Konsole is even worse. Surprisingly, when I ssh from a windows machine the behavior is much better.

Which terminal apps work out of the box without any tweaking for keybindings and mouse support?


texts: How to determine the package version to require in your package?

texts: I have a couple packages now, and in the PackageRequires section I would like to put all the packages I require in it, put it seems like it requires the name and version.  Where do you determine the version number?  For example I have (cl-lib "0.5"), but whats the best way to determine the minimum version I can use?  I can see the current version, but what is the best way to determine the min value needed?  Also, some packages required don't have a version specified in their file.  In those cases, what is recommended?


texts: mu4e folders for multiple accounts (contexts)

texts:
I'm trying to set mu4e to use for both personal and work gmail accounts. I successfully configured offlineimap and fetched the mail.

Then I tried setting mu4e, and according documentation:

  the recommended way to deal with multiple accounts is through mu4e’s built-in Contexts system

Okay. I set the context values like this:

 mu4e-contexts
        `( ,(make-mu4e-context
             :name "home"
             :match-func (lambda (msg) (when msg (mu4e-message-contact-field-matches msg :to "personal-email@gmail.com")))
             :vars '((mu4e-maildir           . "~/.mail/personal")
                     (mu4e-trash-folder      . "/[Gmail].Trash")))
           ,(make-mu4e-context
             :name "work"
             :match-func (lambda (msg) (when msg (mu4e-message-contact-field-matches msg :to "work-email@gmail.com")))
             :vars '((mu4e-maildir           . "~/.mail/work")
                     (mu4e-trash-folder      . "/[Gmail].Bin"))))))

of course there's more than that, I'm showing you only the relevant piece. So the problem I'm having is have to do with deleting messages. Sometimes it works, other times it doesn't. And when it fails it throws messages like this:

  error in process filter: Error 70: error moving /Users/ag/.mail/personal/[Gmail].INBOX/cur/1457242634_2.42730.C02MT2ZDFH05,U=27933,FMD5=4b4b643246a6b95b2136ea99e0e5f614:2,S
to /Users/ag/.mail/[Gmail].Trash/cur/1457242634_2.42730.C02MT2ZDFH05,U=27933,FMD5=4b4b643246a6b95b2136ea99e0e5f614:2,ST

You see that it picked file in personal dir and trying to move to [Gmail].Trash in root of maildir?

Actual directory tree looks more like this:

    /Users/ag/.mail
    ├── personal
    │   ├── INBOX
    │   ├── [Gmail].All\ Mail
    │   ├── [Gmail].Important
    │   ├── [Gmail].Sent\ Mail
    │   ├── [Gmail].Spam
    │   ├── [Gmail].Trash
    └── work
        ├── INBOX
        ├── [Gmail].All\ Mail
        ├── [Gmail].Bin
        ├── [Gmail].Important
        ├── [Gmail].Sent\ Mail
        ├── [Gmail].Spam

Note that mu4e-trash-folder values are different for personal and work. Honestly I dunno why - I set synclabels = yes in my offlineimaprc and that's what I got.

It seems to me, mu4e fails to set correct value of mu4e-trash-folder during context switching. Can someone help me fix that? Show me a piece of config where different folders being used for different contexts? Thanks.


texts: Open files in git repo that have been edited since a previous commit or branch

texts:
Is there a way to provide a list of files that have been edited since a previous commit or branch with helm and projectile integration?

The use case is as follows:

Create feature branch feat-my-thing off of master.
Modify foo.txt and bar.txt
Commit changes.
Days pass. Work on other things.
Revisit feat-my-thing branch.
I'd really like to select from a list of just foo.txt or bar.txt as those are the only files with changes since master.

For small repos, helm-projectile-find-file works well because I can usually remember what I was working on.  With hundreds of files, is not as helpful especially because I'm usually only concerned with 1-5 files for a feature branch.


texts: How to `ediff-buffer` with ansi-colors (script output)? `ediff-file` works!

texts:
Context: files with ANSI and other terminal color codes.

I often record terminal transcripts using the traditional script program or expect.  Colored ls output, colored grep matches, mc and other interactive programs, everything works great and record is faithful!

What works: replaying, opening in emacs

One can replay such files in a terminal, either fast e.g. cat or on own rhythm using less -r (or less -R to see backspaces ^H instead of obey them).
One can open them in emacs and even have emacs automatically apply relevant mode, for example my .emacs.d applies this to any file matching script_*.txt:

(add-hook 'text-mode-hook
          (lambda ()
        (when (string-match "script_.*\.txt$" (buffer-name))
              (progn
        (format-decode-buffer 'backspace-overstrike)
        (format-decode-buffer 'ansi-colors)
        (hide-dos-eol)
        (face-remap-add-relative 'default '((:foreground "white" :background "black")))
        ))))

What fails: emacs accepts ediff-files, refuses ediff-buffers. Why? How to solve?

Detail of what works: comparing with ediff-files works

This opens files straight into ediff, perfectly:

emacs --eval '(ediff-files "script_file1.txt" "script_file2.txt" )'

Differences are shown, colors from ANSI codes are blended with colors from ediff which was not expected as obvious.

Calling ediff-files interactively also works.

The fact is, I just figured out ediff-files works, while searching to write this question. I never ediff-files because it's much more convenient to open files with any of the convenient ways (dired, etc) then ediff-buffer after opening. ediff-buffer offers straightforward completion among the opened buffers, which is more selective/relevant.

Detail of what fails: opening files interactively then invoking ediff-buffers fails

ediff doesn't start, minibuffer shows:

  "Sorry, `ansi-colors' format is read-only"

Notice that the very same buffers that have just been compared using ediff-files, when closing ediff then calling ediff-buffers yield same failure.

Detail of what fails: saving file

Trying to save a file decoded with tty-format/ansi-colors fails, too.

How to solve?

A good netizen searches before they ask.  Error message appears in package tty-format.  Browsable copies of source code appear in various places, e.g. on https://github.com/grantdhunter/dotfiles/blob/8c11b417a373d4a8eb7a4b3772ebf956e825edfc/emacs.d/tty-format.el#L226

It looks like there is an avoidable obstacle.

It looks like buffers opened with ansi-color encoding have "lost something", they have been reencoded internally by emacs and cannot be saved again.  I can understand that ANSI codes that move cursor around to produce a composite buffer make not obvious what to do when saving again.

Possible workaround: recovering convenience of ediff-buffer

I have an idea of a possible workaround but am not savvy enough in emacs-lisp.

Q1: Can someone make a function which would offer completion by buffer names (like ediff-buffers) but would actually figure out underlying files and calls ediff-files on them?

Any better idea is welcome.

Possible workaround for impossibility to save: instruct emacs to save them into another format, possibly warning about lost information

This makes sense when saving snippets of text, e.g. as plain text, as color HTML, whatever. (Notice: htmlize-buffer does not fit, practically does no better than plain text.)

Q2: Is there a way to tell emacs "when saving this file, instead of refusing at all, offer me to save to a different location and format"?

I expect this would have a side-effect of allowing ediff-buffers to work immediately and lose color information, but maybe not.

Something else?

Perhaps there is another way to handle files with ANSI color codes that doesn't have these problems at all?

Thanks anyway.


texts:
I use org-mode to take notes. Currently I have a root directory, say, "Notes", and there are several subdirectories inside it, for example, "Linux", "Programming", etc. The notes taken using org-mode are stored under those subdirectories.

I was wondering whether there is an available set of settings so that I can search these notes(which are all org-mode files) very quickly. I know there is deft, but it is not designed for org-mode files. Actually I also tried helm-projectile but it's far from satisfactory.

To be more precise, what I want to achieve is that I can search these files using tags, headlines, or other features which are org-mode-related, maybe using some predefined syntaxes. And if possible, I would prefer something like helm. If there is no such an extension, will it be worth to implement such an extension? I thought deft+helm-projectile might be a good start point.

UPDATE: I tried both methods, directory-local variables(as @itsjeyd suggests in the answer) and org-agenda-custom-commands, and I found the latter one seemed more convenient. So here is my setting:

(setq org-agenda-custom-commands
  '(("n" . "Search in notes")
    ("nt" "Note tags search" tags ""
     ((org-agenda-files (file-expand-wildcards "path/to/Notes/*/*.org"))))
    ("ns" "Note full text search" search ""
     ((org-agenda-files (file-expand-wildcards "path/to/Notes/*/*.org"))))))


texts: What are the differences between autocomplete and company mode?

texts: There seem to be two major autocompletion extensions for emacs: autocomplete and company mode. What are some of the practical differences between the two and when would I want to use one over the other? Also, are they compatible with each other?


texts: Edit org-mode tags using ido or ivy completion

texts:
I'd like to try a different method of specifying tags than the built-in single character codes.  How can I tag headings using ido or ivy completion?

I think I would like at least two commands:

Toggle a single tag on a heading
Edit the list of tags for a heading

For what it's worth, I want to use flex matching for this (I don't think that's relevant, so I say that just to give as much intent as I can).

I'm not using org-capture


texts: Insert a node at a specific place in org-mode

texts:
I'd like to insert a node into a specific place.

Each day, I log in, expand the following nodes: "Engineering worklog" > "2019" > "Q2" > "week 20" > "05/20/15".

I'd love to have a single command to insert all of that at the correct place in my org file, but I can find precious little about inserting nodes into a large org-mode file.

Anyone have something like this or pointers for me?


texts: Cycle through multiple cursors to enter different text at each point?

texts:
When multiple cursors has marked multiple points in a buffer you can use C-v (mc/cycle-forward) to cycle through and look through all cursors while typing for all cursors.  I'm wondering how to enter different text at each cursor point while retaining the mc/cycle-forward cycling behavior or working with mc as seamlessly as possible.

A rough use case (possibly positioning #5 after #7):

mc/mark-all-like-this or equivalent to create multiple cursors
[usual mc interaction with all cursors]
[some action to indicate interaction with a single cursor]
enter text at current cursor
hit C-v an arbitrary number of times to select a different cursor
enter text / move point of a now different current cursor
[some action to restore standard mc behavior]
[resume interaction with all cursors]

I currently use isearch-forward to fill in for this (for example to fill in different section headers in an html document), but this drops me out of mc and forces me to re-mark.


texts:
I have this error when I start emacs:

File error: Searching for program, no such file or directory, git

My Git is inside the VM in /usr/bin/git

How can I point emacs to it?

I'm using tramp and plink to communicate the VM and emacs.

I tried leaving in the .emacs file

(add-to-list 'exec-path "/plink:asti@192.168.33.10:/usr/bin/")

But it didn't help.

I also tried to install Git into windows but then when I visit Git repositories in the VM, Git from windows doesn't have access to the remote FS. Specifically, I press M-x magit, and emacs says:

Git repository:<path to where I am>

Then I press enter

Then it says:

 Create repository in /plink:asti@192.168.33.10:<path to where I am>

Whether I press Y or N, it doesn't help me.

Does anyone have any suggestions? How do I configure Magit to use the git binary on the remote machine?

Thanks