texts:
If I have required a dynamic module in emacs, and then modify the source and rebuild it, how do I get emacs to reload the new module? I have not been able to just require it again. The only thing that works so far is to give the module a new name.

For example, here is a little c code that makes a module (adapted from http://nullprogram.com/blog/2016/11/05/)

#include "emacs-module.h"

int plugin_is_GPL_compatible;

int
emacs_module_init(struct emacs_runtime *ert)
{
    emacs_env *env = ert->get_environment(ert);
    emacs_value message = env->intern(env, "message");
    const char hi[] = "Hello, cruel world!";
    emacs_value string = env->make_string(env, hi, sizeof(hi) - 1);
    env->funcall(env, message, 1, &string);
    return 0;
}

You compile it with:

gcc -Wall  -fPIC -c hello.c
gcc -shared -o hello.so hello.o

Then load (note in this case we have to load it because we did not provide any feature, so require does not work here) it with (assuming it is not built on your path):

(add-to-list 'load-path "path to hello.so")
(load "hello")

And you will get a message in Messages of "Hello, cruel world!"

Now, you decide to change the message to "Hello, world!" you recompile the c code and reload it, but you still get the old message.

You can restart emacs to get it to work, or start a second emacs for testing as suggested, but this is not something I usually have to do when writing elisp modules. You can also change the library name, but it is tedious).

You cannot (unload-feature 'hello) in this case, because it is not a feature. It turns out in more complete examples that do provide a feature, you cannot unload that feature either.


texts: How to preserve system command key behaviors in emacs-mac

texts:
I am exploring switching from Emacs for Mac OS X (that is, the official GNU Emacs, compiled for macOS: https://emacsformacosx.com ) to the emacs-mac port, Mitsuharu Yamamoto's version of emacs with additional support for macOS ( https://bitbucket.org/mituharu/emacs-mac/ ).

My reason for switching is to want better, more idiomatic Mac support, so I'd like to configure emacs-mac so that it uses the alt/option key for meta, and supports the as many as possible of the normal system keybindings for the command key? That is, I want to support CMD-S for save, CMD-C for copy, CMD-V for paste, CMD- for end of line, etc..

The closest I have come is this snippet, but this merely disables that CMD key rather than reproducing or revealing default Mac behaviors:

(let ((is-emacs-mac-by-yamamaoto
       (and (boundp 'mac-carbon-version-string)
            (string= window-system "mac"))))

  ;; let "alt/option" key work as META
  ;; (instead of acting as it usually does for text entry)
  (setq mac-option-modifier 'meta)

  ;; Disregard the "command" key entirely
  ;; (instead of using it for META)
  (setq mac-command-modifier nil)

  ;; let "command" key pass to system
  (setq mac-pass-command-to-system 't))


texts: What is causing my javascript files to auto-format?

texts:
If I have a long line in a javascript file such as:

  let args = [options.loadRaw ? buffer : path.resolve(filePath)].concat(options.commands);

At some point when I keep adding to that line, it auto-formats into:

  let args = [options.loadRaw ? buffer :
              path.resolve(filePath)].concat(options.commands); // test

I'm trying to figure out what is causing this, because it's pretty jarring. I'd rather run this myself manually when I want to like with clang-format. I'm using js2-mode so I have a feeling it's that but I can't figure out what it may be or if it can be disabled.

I know it's pretty vague but I don't know what else to say. I'm mainly wondering if there's a way I can find out for myself. I did C-h k before pressing the space key but it's just self-insert-command, though I noticed that there's this in the help buffer for that function:

After insertion, the value of ‘auto-fill-function’ is called if the
‘auto-fill-chars’ table has a non-nil value for the inserted character.

But I checked and auto-fill-function is nil, otherwise that definitely seemed like the culprit. Then I saw this at the end of the help buffer:

At the end, it runs ‘post-self-insert-hook’.

Whose value is:

(sp--post-self-insert-hook-handler helm-find-files--reset-level-tree electric-pair-post-self-insert-function electric-indent-post-self-insert-function blink-paren-post-self-insert-function)

I'm not sure if this is correct, but I did (setq post-self-insert-hook nil) in the buffer and then pressed space and it still re-formatted the line, so maybe it's something else? I'm entirely at a loss.

I'm not sure if this is related, but to see if it was js2-mode buffers I also just noticed some other behavior when in the *stratch* buffer. If I type out a sexp with just one repeated over and over, once I get to the fill-column it starts adding spaces, like this:

(one one one one one one one one one one one one one one one one one one one one      one one one one one)
                                                                                ^ fill column here (column 80)

That's certainly different from what happens in js2-mode buffers though, where the line is entirely re-formatted onto separate lines so that it fits within the fill-column.

I'm on emacs 25 in case that matters.

EDIT: Disabling auto-fill-mode fixes the issue. The problem is that I want to keep auto-fill-mode. It looks like js2-line-break is the culprit:

  (set (make-local-variable 'comment-line-break-function) #'js2-line-break)

My configuration of auto-fill-mode is:

  (defun my-prog-auto-fill ()
    (setq-local comment-auto-fill-only-comments t)
    (auto-fill-mode 1))

  (add-hook 'prog-mode-hook #'my-prog-auto-fill)

What I don't understand is why, if I setup auto-fill to only apply to comments, and the variable that js2-line-break is being assigned to is called comment-line-break-function which gives the impression that it only applies when within a comment, why then is js2-line-break being called despite not being within a comment?


texts: Add flags for the compiler used by flycheck

texts:
I am trying to run flycheck with c++-code which imports the thread library. thread requires -std=c++11 which is not used with the c/c++-gcc setting.

Is there a way to add this flag or to solve this in a some other way?


texts:
Running Doom Emacs 2.0.9 on Emacs 27.1.
In an org file, I have:
* First heading
  :PROPERTIES:
  :ID:       89f7215b-60b1-45c8-8262-b0e10db18f4c
  :END:
* Second heading

I got that ID by using org-id-store-link function.
Now, I want to insert a link to that heading. So, I did org-insert-link and it displayed various options. I was looking forward to some kind of auto-completion --- I start typing Firs.. and it suggests the correct link.
But that does not seem to be happening.
How do I get that behavior?


texts: Spacemacs crashing on start with Ubuntu 20.04

texts: I'm having a problem where every time I open Spacemacs it immediately crashes on Ubuntu 20.04. It was crashing for some actions with Magit and starting a CIDER REPL so I decided to do a fresh install. Here is my .spacemacs file.


texts: How to change/remove an existing but unneeded keybinding?

texts:
Some of the packages I use define keybindings that I want to overwrite or remove.  How do I overwrite/remove these keybindings?

For example, I use ace-window and speedbar together.  ace-window uses M-p for switching windows, and I want to keep that binding. However, it's used by speedbar for speedbar-restricted-prev with (define-key map "\M-p" 'speedbar-restricted-prev) in the source).

I don't know what speedbar-restricted-prev does and I don't think I will be using it. This is how I have configured ace-window. What else do I need to do to disable the binding of M-p in speedbar? Outside of speedbar it works.

(use-package ace-window
  :ensure t
  :defer t
  :init
  (progn
    (global-set-key (kbd "M-p") 'ace-window)
    (setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l))
     ;;more info at https://github.com/abo-abo/ace-window
    ))


texts:
Is there any way to easily find all the modes that derive from a mode?

The closest I can get is to use M-x apropros and search for -mode$ and manually comb through all defuns with the property derived-mode-parent and peek at them to see if they derive from the mode I am interested in. I suppose I could write a routine to do that quickly, but I'd rather not if I can help it.


texts: Probe emacs version from within a .emacs file?

texts: I want to have a single .emacs file, under version control. Unfortunately, different systems have different versions of Emacs running. How do I detect the Emacs version from within Elisp?


texts: emacs indentation style in file local variables

texts:
I am using emacs 24.5 and I ran into a problem with file local variables.

I am working on a git project where file local variables are set like:

/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */

However, they seem to be using unindented namespaces.
But when I indent the whole buffer I also get namespaces indented.

Is this the desired default behaviour? How can I override the namespace indendation?

I tried the answer mentioned here:
https://stackoverflow.com/questions/2619853/emacs-override-indentation

But I want to do this only for the current project, thus I tried to put it in a .dir-locals.el file.

I tried:

((cc-mode (eval add-hook 'c++-mode-hook  (lambda() (c-set-offset innamespace [0])))))

I also tried:

 ((cc-mode . (c-offsets-alist . ((innamespace . [0])))))

I also tried changing the style in my dir-locals.el, but none of them seem to override the file local setting. Is this a priority issue of file local variables?


texts: Nonexistent newline on display after using outorg

texts:
I'm using outorg to convert an elisp file to an org file and then back to an elisp file via (outorg-convert-to-org) and (outorg-convert-back-to-code). When I do this conversion I notice that it looks like there is an extra newline between headlines and source blocks. On the image below the left is my original elisp file and the right is after the conversions. It seems as if the conversion added an extra newline between the comment and the code. However, when saving the contents of the buffers before and after conversion and testing for this via (string= original-buffer-contents after-conversion-contents) I get t. So the buffer contents are the same.

Upon further investigation, I can't move the cursor over the "extra newline". It always skips it. I suspect that there is no actual newline added to the buffer contents and this is some sort of visual (bug?) thing.

What's happening here? And how can I prevent this "extra newline" from displaying?

UPDATE:
This is what is displayed when I use describe-char just before the (nonexistent?) newline. The character is described as a newline.

Another thing I found interesting is what happens when I try to delete it (e.g. by putting my curser before the (defvar and pressing backspace). If the extra newline existed, pressing backspace twice should leave the commented line on the line above (defvar line. However when I press backspace twice (the right window in the picture below) the two lines are joined on the same line indicating the extra new line is not really there.

The left window is the result of pressing backspace one time on the original buffer.


texts: clang-format package looking for wrong executable

texts:
I'm trying to setup emacs to use the clang-format package.  I have installed the clang-format package from MELPA and also have clang-format-10 (apt install only installs version 6 on Ubuntu) installed on my local machine.  I also have the following lines in ~/.emacs:
(require 'clang-format)
(setq clang-format-style "file")
(setq exec-path (append exec-path '("/usr/bin/clang-format-10")))

I added the last last line because M-x clang-format-region throws the error:
Searching for program: No file or directory, clang-format

However, the clang-format package appears to still be looking for a clang-format binary without the version suffix.  Also, it's worth noting I made an alias in my ~/.bashrc so clang-format points to clang-format-10, however that doesn't help me in emacs.


texts: Org-mode: Entering time with academic quarter as 2ct

texts:
One can enter the time 14:00 by typing 2pm.  One should also be
able to enter 14:15 by typing 2ct.  ('cum tempore' indicating an
academic quarter.)  Is it possible to get this behaviour?

(Or 14ct.  Ideally, one would have a function to determine whether an academic hour is likely to be am or pm.)


texts:
I'm on ubuntu 14.04 64 bit, I had emacs 23 working great, I removed it to install emacs 24 and I get this error

emacs
X protocol error: BadMatch (invalid parameter attributes) on protocol request 139
When compiled with GTK, Emacs cannot recover from X disconnects.
This is a GTK bug: https://bugzilla.gnome.org/show_bug.cgi?id=85715
For details, see etc/PROBLEMS.

(emacs:776): GLib-WARNING **: g_main_context_prepare() called recursively from within a source's check() or prepare() member.

(emacs:776): GLib-WARNING **: g_main_context_check() called recursively from within a source's check() or prepare() member.
Fatal error 6: Aborted
Backtrace:
emacs[0x4f74cb]
emacs[0x4dcf3e]
emacs[0x4f7513]
emacs[0x4b219b]
emacs[0x4b420c]
emacs[0x4b426d]
/usr/lib/x86_64-linux-gnu/libX11.so.6(_XError+0x12b)[0x7f2ade76854b]
/usr/lib/x86_64-linux-gnu/libX11.so.6(+0x3b5e7)[0x7f2ade7655e7]
/usr/lib/x86_64-linux-gnu/libX11.so.6(+0x3b695)[0x7f2ade765695]
/usr/lib/x86_64-linux-gnu/libX11.so.6(_XEventsQueued+0x55)[0x7f2ade765fc5]
/usr/lib/x86_64-linux-gnu/libX11.so.6(XPending+0x4d)[0x7f2ade75812d]
...
[1]    776 abort (core dumped)  emacs

So it crashes every time I try to start it


texts: What is the difference between `M-f` and `C-right`?

texts:
The documentation states the following:
(forward-word &optional ARG) is bound to M-f
(right-word &optional N) is bound to C-right
Could there be any difference between the two? It just doesn't seem right to me that a software as elegant as Emacs has two functions that do essentially the same thing... Thanks in advance!


texts: Indentation incorrect in line with `if:` or `unless:` as options, not directives

texts:
In some of my ruby files, mostly Rails Model files, I often encounter lines such as:

  validates :thing_id, presence: { message: '^Choose a Thing' },
    on: :create,
    unless: Proc.new { |obj| ... some condition ... }

Where the unless: is treated like the unless directive, and so throws the indentation off for the rest of the file. This also happens with an if: option.

Has anyone found a solution for this?


texts:
I'm trying to devise a function which returns the class name. I would like to call that function inside a Yasnippet snippet for PHP-mode, so the class name will be inserted inside the template snippet.

After reading Emacs documentation, I found which-function-mode, which it returns a function name. But nothing about class names, unfortunately. Do anyone know a alternative way to get the class name of the position/current buffer?

Edit: I found an regex in the imenu source code that matches the name of the classes in PHP. But now I'm wondering how he could returns the result for yasnippet:   ("^\\s-*\\(?:\\(?:abstract\\|final\\)\\s-+\\)?class\\s-+\\(\\(?:\\sw\\|\\\\\\|\\s_\\)+\\)" 1)


texts: Disabling the special meaning of either `+` and/or `|`

texts:
I came across a case where strike-through and table interfere with the proper operation of org-links (which, in my case are org-ref citations). Here is a minimal example:

+-+
|cite:VemulaMO2016c-Path-Plann

This link is dead. However, if any of the four other characters is removed, the link comes alive. Whether this is a bug or not, can I somehow disable the special meaning of either + or | (not just the mark-up and highlighting) for the current buffer?


texts: Color-code a new generic character combination

texts:
I'm new to Emacs and Org-mode, this is a very basic question. Unfortunately the keywords are too common for me to find the answer.

I would like to create a custom pattern to colour my writing input.

Something like

_theorem: (it would detect _ and a non-whitespace character for the start, and would trace it until the end, or colon)

_theorem 2: (it would be great if this could also include whitespaces)

_theorem on topic 1: (such as this).

The script would thus automatically color all of the above writing that is now in bold. References that would help me do this would also be helpful. Many thanks for helping a beginner!

Update

I've added a follow-up question in the comments on adding multiple such rules that ran into problems. Here's the full code for it. While the first answer to the first question is working perfectly now, the other two new rules seem to be mistakenly formulated or in conflict somehow. On the instances where either of them is found, it breaks the regular  coloring of org-mode and does no coloring itself.

(add-hook 'org-mode-hook
          (lambda ()
                (font-lock-add-keywords nil
                                    '((
                                    "\\(^\\|\\s-+\\)\\(_\\([a-zA-Z0-9]+\\s-?\\)\\{0,4\\}:\\)" 2
                                    font-lock-type-face t)))
                (font-lock-add-keywords nil
                                    '((
                                    "\\(\\w+\\(\\s-&\\s-\\w+\\)?,\\s-[0-9]\\{4\\})" 2
                                    font-lock-type-face t)))
                (font-lock-add-keywords nil
                                    '((
                                    "^\\w+:" 2
                                       font-lock-type-face t)))
))


texts:
I would like to use org-mode's contributed packages:
http://orgmode.org/worg/org-contrib/

[EDIT] SOLUTION:

As per answer below:
1) First one should have the elpa packages added.

(require 'package)
...
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)
...
(package-initialize)

This is described [here] in detail.1

2) Afterwards, below the lines above, one can add the desired modules like this:

(require 'org-checklist)

WARNING
Some packages may be available in the git-hub repository but not yet in the official repository. (e.g org-eww at the time of writing).
As such, requiring these will cause errors.

Before adding a requirement, it is reccomended to browse the folder:

~/.emacs.d/elpa/org-plus-contrib-<DATE>


texts: Ways to open the compiled pdf file of the current tex file

texts:
I would like to define a customized function to open the complied pdf file of the current tex file in the default pdf viewer of the system (say SumatraPDF.exe).

I am primarily interested to a solution without AUCTeX/LateX mode facilities, though such a solution would be also useful.


texts: Getting more than 8 colors in a terminal emulator inside Emacs

texts:
My understanding is that ansi-term only supports 8 colors (a good discussion of this in reddit here).

Meanwhile, an increasing number of terminal emulators (e.g. tmux or iTerm2 in OS X) support True color (24 bit, i.e. 16 million colors). A good list can be found here.

If the 8-color cap is specific to ansi-term, are there any other packages for terminal emulation that are trying to address this limitation?
Are there any plans to bring True color support to a terminal emulator in Emacs?

And maybe to confirm:

Is there any way to effectively have more than 8 colors in  ansi-term buffers?
Is tweaking ansi-color-names-vector still the recommended way of setting ansi-term colors in Emacs 25?

How to test if an emulator supports "True color":

Here is a snippet from the link above that would test if the emulator supports True colors:

awk 'BEGIN{
    s="/\\/\\/\\/\\/\\"; s=s s s s s s s s;
    for (colnum = 0; colnum<77; colnum++) {
        r = 255-(colnum*255/76);
        g = (colnum*510/76);
        b = (colnum*255/76);
        if (g>255) g = 510-g;
        printf "\033[48;2;%d;%d;%dm", r,g,b;
        printf "\033[38;2;%d;%d;%dm", 255-r,255-g,255-b;
        printf "%s\033[0m", substr(s,colnum+1,1);
    }
    printf "\n";
}'

If it is supported, the bottom line would display a nice gradient like the one shown below:

From what I read, NeoVim (a VIM editor) added support for it in 2015, and there was a request made to Emacs bugs to add it.


texts: Installing Auctex from Package Manager: Scan error

texts:
When install auctex from the Package manager using GNU Archive, I get this error:

forward-sexp: Scan error: "Unbalanced parentheses", 18984, 38451

This always happens to me when I install it using the package manager. If I instead install it manually then everything works. Is there a way to solve the above error ?


texts:
In dash.el, there are anaphoric macros (it saves to write "lambda":

(--map (* it 2) '(1 2))

instead of (-map (lambda (it) (* it 2)) '(1 2)))

seq.el is more generic, it works on strings and vectors too, but it doesn't include anaphoric macros (and doesn't intend to, AFAIK).

Are you aware of a library that implements them ?

Thanks.

edit: in the needs, wrote a couple of them: https://gitlab.com/emacs-stuff/anaphoric-seq


texts:
I'm trying to install (and run) scilab-mode, but the syntax highlighting does not work when I open .sci or .sce file.

I use the exact configuration described in the scilab.el package.

https://www.emacswiki.org/emacs/scilab.el

Any help?


texts: how to change C-mode syntax so that the token @' is ignored?

texts:
I edit some files that are mostly C code but include a few special extension tokens.  The tokens that give c-mode a problem are @' and @".

I essentially want c-mode to ignore these two bigrams.  The current behavior is that the quote (single or double) is interpreted as the beginning of a quoted string.

I reckon this is childs play for anyone well versed in elisp syntax tables but I am not hence my appeal for your help.


texts: org-edit-special to respect the :lines parameter of `+INCLUDE`s

texts:
When one invoke org-edit-special at the line containing an #+INCLUDE, it opens a new buffer with the referenced file. Although, if an #+INCLUDE contains the :lines clause it will not respect what is written in it.

Is there a method to enforce opening file at the place referenced by the :lines parameter?


texts: Hide org-table rows outside certain date ranges?

texts:
Excel tables lets us show just the rows that have "July 2018" in a specific column, and hide the rest. Or to show "21st August 2017-30th August 2017, and also July 2018, and also all of 2019", and filter away the rest

How can we most easily do this with org-tables?


texts:
When playing around with data in calc, I often want to generate a vector from an interval.

How can I easily create a vector from just a start point, end point & step value.

Something like 1 <RET> 10 <RET> 1 MAKE-VECTOR to give me [1,2,3,4,5,6,7,8,9,10]?


texts:
I just grabbed csv from elpa (melpa) and, of course, the install buffer had the blurb about csv. I take it that blurb is an Info file somewhere? Or is it just a section of the csv.el comments? In other words, where can I access these usage instructions once I've installed csv?

Investigating, I did C-h v for Info-directory-list which I assume will give me a list of all the Info files' directories? This is what came up:

("/home/me/.emacs.d/elpa/auctex-12.1.0" "/home/me/.emacs.d/elpa/ebib-20180111.30" "/home/me/.emacs.d/elpa/ess-20180123.1313" "/home/me/.emacs.d/elpa/geiser-20171217.1353" "/home/me/.emacs.d/elpa/haskell-mode-20171022.26" "/home/me/.emacs.d/elpa/magit-90150116" "/home/me/.emacs.d/elpa/org-plus-contrib-20180122" "/home/me/.emacs.d/elpa/ivy-20180115.1555" "/home/me/.emacs.d/elpa/org-20180122" "/usr/local/share/info/" "/usr/share/info/" "/usr/local/share/info/")

It says this variable Info-directory-list is defined in info.el, but then where do these specific directory listings that appear in the list form above reside? They're not in my init.el.


texts: Can't auto set "Group directories" (dired-quick-sort) when start Emacs

texts:
Linux Mint 20.1
Emacs 26.3
Install package:
(require 'dired-quick-sort)
(dired-quick-sort-setup)

https://github.com/emacsmirror/dired-quick-sort
And I want to show first directories in dired mode. To do this I press S and select Group directories = yes (g).
And here result.

Nice. It's work correct. But the problem is... when I restart Emacs I need AGAIN to set this sort manually.
Is it possible to autoset this sort (by Group directories) when start Emacs?


texts: How do I use a numeric prefix to repeat a list of numbers?

texts: Suppose I want to type '222222' in emacs, how do I use the numeric prefix idiom to achieve this?  A naive guess would be 'C-u 6 2' but emacs interprets this as a numeric prefix of 62 and waits for the next command.


texts: Change er/mark-method-call() - based on regex - to include square and curly braces

texts:
This is a function definition from expand-region.el, which does not accept new Issues.
It looks at (), but not at [] or {}. How to change it to include other pairs too?
(defun er/mark-method-call ()
  "Mark the current symbol (including dots) and then paren to closing paren."
  (interactive)
  (let ((symbol-regexp "\\(\\s_\\|\\sw\\|\\.\\)+"))
    (when (or (looking-at symbol-regexp)
              (er/looking-back-on-line symbol-regexp))
      (skip-syntax-backward "_w.")
      (set-mark (point))
      (when (looking-at symbol-regexp)
        (goto-char (match-end 0)))
      (if (looking-at "(")
          (forward-list))
      (exchange-point-and-mark))))

I want to be able to mark foo['bar'] in Python.


texts:
I currently have the hook below for displaying tabs when in text mode:

(add-hook 'text-mode-hook
          (lambda () (standard-display-ascii ?\t "!---")))

I only want that setting to apply in text mode.

The problem: Once I open a text file, the above setting will be set for all subsequent buffers that I open. That is not the desired outcome. How can I apply a setting to only one mode?


texts: disabling evil auto copying of selection to clipboard on frame focus

texts:
I'm seeing interesting behavior when I try to copy text between other applications and emacs on arch linux, when using evil-mode.

Whenever I have a region selected in emacs, and then click to focus chrome, the region selected is my clipboards contents. I actually only want my region copy'd to my clipboard when I yank.

Also whenever I copy text in chrome, and then focus my emacs window, If I already have a region selected in emacs, that region is now what evil-paste-after produces. I expect my copied text from chrome to be pasted, not the region I happen to have selected.
If I have no visually selected region in emacs, then then my next evil-paste-after is actually my copy from chrome.

I've seen others remark about mouse-drag-copy-region and have the line
(setq mouse-drag-copy-region nil) set in my config. This setting seemingly works for me when I'm not using evil-mode. But with evil-mode enabled, my mouse selections end up copying to the clipboard.

I believe this answer may solve my issue if I can alter it to be for my platform, instead of OSX

These questions also may be related

How to disable emacs evil selection auto copies to clipboard
Pasting in evil-mode when there's an active selection copies the selection


texts:
What is the best way to use Magit with GitHub personal access tokens?

Right now, pushing to GitHub causes Magit to prompt me for a username and password. I have to provide the access token instead of my regular password to authenticate.

Apparently, cloning with SSH instead of HTTPS is the way to go. However, I've already cloned a large number of repos w/ HTTPS. Can I get them to use the token I've specified in my .gitconfig file?


texts:
In an Org document I type

call the /static/ method =something(/$with/, /$param/)=

and (thanks to org-hide-emphasis-markers set to t) it appears as

  call the static method something($with, $param)

both in graphic mode and --no-window-system mode. Just what I want.

But then when I export it to HTML, results

call the static method something(/$with/, /$param/)

How can I convince the exporter to italicize inside verbatim or code too?


texts: How to indent without the two extra spaces at the beginning of code blocks in org mode?

texts:
By default org mode source blocks looks like:

#+BEGIN_SRC emacs-lisp
  (dcg/add-to-list 'package-archives
                   '("melpa-stable" . "http://stable.melpa.org/packages/")
                   '("melpa" . "http://melpa.org/packages/")
                   '("marmalade" . "http://marmalade-repo.org/packages/"))
  (package-initialize)
  (setq package-enable-at-startup nil)
#+END_SRC

Is it possible to configure it to indent without the two beginning spaces like:

#+BEGIN_SRC emacs-lisp
(dcg/add-to-list 'package-archives
                 '("melpa-stable" . "http://stable.melpa.org/packages/")
                 '("melpa" . "http://melpa.org/packages/")
                 '("marmalade" . "http://marmalade-repo.org/packages/"))
(package-initialize)
(setq package-enable-at-startup nil)
#+END_SRC


texts: Trigger custom function when `*Scratch*` is recreated

texts:
I would like to run a custom function whenever a new *Scratch* buffer is created because the last uninteresting buffer was killed.  I looked at both the C source code and window.el and it appears that Lisp has nothing to do with the *Scratch* buffer being displayed in a particular window, but I'm not 100% certain.  It appears as though tem = Fother_buffer (buffer, Qnil, Qnil) within kill-buffer is what leads to the creation of a new *Scratch* buffer.

Is there anything other than the buffer-list-update-hook that I could use to trigger my custom function when a new *Scratch* gets spawned?  I don't think that replace-buffer-in-windows is any help in this context.

[I don't really want to advise get-buffer-create.]


texts: Set region to include enclosing parentheses

texts:
Starting with the point or active region, how do I quickly (in one keystroke / command) 'expand' to include the next set of enclosing parentheses?

If I start with: (| means point)

(defn foo [x] (+ x |42))

Or if I start with: (< and > bracket the selected region)

(defn foo [x] (+ x <42>|))

I want to end up with

(defn foo [x] <(+ x 42)>|)


texts:
I am trying to write a snipped mode for writing subscripts in LaTeX:

# -*- mode: snippet -*-
# name: sub
# key: _
# --
_{\text{$1}}$0

If I type just _ + TAB it expands correctly  as expencted. But if there is a character before _, it doesn't expand at all. However this is the case where I need it. For example

x_ + TAB should expand to  x_{\text{}}

If this is not possible in yasnipped, what would be the best way to get exactly this in emacs?


texts: Text is black on startup --- how to debug?

texts:
I just helped a colleague to configure package.el, smex, and ido and set up a nice theme (spolsky from the sublime-themes package) for Aquamacs.

When I evaluate (load-theme 'spolsky t) everything looks just fine, but when Aquamacs is started, the main text that is supposed to be white is black.  This is fixed when I manually evaluate (load-theme 'spolsky t) with C-x C-e.

The configuration file is minimal and nowhere do I change any colours explicitly.  The only theme-related line is (load-theme 'spolsky t).

Since this is Aquamacs and not GNU Emacs (which I'm using) I don't really know how to debug this.  (I don't even know how to run a GUI Aquamacs from the command line because I'm completely Mac-illiterate.)

How can I debug this?  There is no error message displayed and the equivalent of custom.el does not mention any colours.


texts: Auto complete with tab not working in IPython

texts:
I installed Emacs for Python (from this github repo) on my Emacs 24.5.1. When I start an IPython shell, auto-complete with tab doesn't work. Instead, the tab key just insert four spaces. But if I press Enter leaving those spaces, the auto-complete suggestions appear in the buffer.

For example:

In [6]: import numpy as np

In [7]: x = np.arr

np.array         np.array_equal   np.array_repr    np.array_str
np.array2string  np.array_equiv   np.array_split

np.array         np.array_equal   np.array_repr    np.array_str
np.array2string  np.array_equiv   np.array_split

In [8]:

After x = np.arr, I pressed tab twice before Enter, and then all suggestions appeared at once.

If I press M-/, Emacs tries to auto-complete the name, but it doesn't show me all options. In the example above, I would have to press it many times to cicle through all available completions.

My .emacs file is as follows:

(load-file "/home/erickrf/.emacs.d/emacs-for-python/epy-init.el")
(epy-setup-ipython)

;; disable auto parenthesis completion
(setq skeleton-pair nil)

(put 'erase-buffer 'disabled nil)

This is a similar problem. I tried the solution in the accepted answer, but it didn't work for me. Whenever I pressed tab, Emacs would show the error message Symbol's value as variable is void: python-shell-completion-complete-or-indent


texts: How to use mouse click to the right or to the left of the text to move cursor to this line?

texts:
On a mouseclick to one side of the text, it can be convenient to make the cursor jump to:

the beginning of the line (when clicking left of the text)
the end of the line (when clicking right of the text)

This is the default behaviour of most text editors (also the one used for editing this very entry), so it can help to make emacs more beginner (user?) friendly.
Currently, the cursor either doesn't move (1.) or it jumps to the beginning of the next line (2.). Most people probably use C-E instead, but it would be good to be able to leave that out.


texts: Org LaTeX export: set default options for documentclass

texts:
Is there variable like org-latex-default-class-options which will set default options for \documentclass like file variable #+LATEX_CLASS_OPTIONS do?

This situation similar to variables #+LATEX_CLASS and org-latex-default-class.  I've found How do I configure class options for latex export in my .emacs?, but it's one-year-old and not so trivial.


texts: Not successful to enter mmm-jinja2 mode after installation using MELPA

texts:
So what I have tried is to first install the package by using MELPA:

M-x package-install RET mmm-jinja2

I looked up where the package have been installed and found it to be at "~/.emacs.d/elpa/mmm-jinja2-0.1/mmm-jinja2.el" so now I am trying to load it in my ~/.emacs file, I do this by simply following the instructions on their GitHub page, only changing where my package is stored

(load "~/.emacs.d/elpa/mmm-jinja2-0.1/mmm-jinja2.el")
(add-to-list 'auto-mode-alist '("\\.jinja2\\'" . html-mode))
(mmm-add-mode-ext-class 'html-mode "\\.jinja2\\'" 'jinja2)

Next I restart emacs and it load the init-file file just fine, but still I am unable to use the package, it can not be found among my modes. I have made sure to have both mmm-mode and python-mode installed and working also, so it probably is not because of a dependency.

Where should I start to debug in order to find where the problem may be?


texts: How to solve non-persistence emacs frame title?

texts:
Some people had the same issue:

frame title as buffer file resets to default after some time
How to make frame-title-format persistent?

I've tried to change frame-title-format value to:

(setq frame-title-format '(multiple-frames "%b" ("" invocation-name "@" "foobar")))
(setq frame-title-format "%b")

Both works for several seconds then changed to default invocation-name "@" system-name after switching to several other windows.

This happened only when emacs in non-active window state: when it becomes an inactive window, it uses the default value, but when it becomes active window it uses 'user' frame-title value.

I use I3 Window Manager with stacking layout, so I know exactly when the title reverts back to default inconsistently.

I tried using emacs -q, yes the problem disappear. But Anyone knows the solution?

The horrible trick that I can use is setting system-name to fake name (setq system-name "foo"), but I'm sure this will create problem in future. Other trick is using (set-frame-name "Foobar") but it didn't update even I use (set-frame-name (concat invocation-name " - " (buffer-name)))

I don't want my username/machinename in the application title.


texts:
I subscribe  gwene.com.stackexchange.tex from gnus.

The images  includes in an article are displayed as a black rectangle. After a lot of time images can display as they should, but after emacs-restart the issue is back.

I try to open a downloaded png image with eww-open-file. Same result.
My Emacs-version is GNU Emacs 26.1 (build 2, i686-pc-linux-gnu, GTK+ Version 3.24.0)

Starting emacs -q makes no difference nor does Emacs25.

It must exist something which trigger the correct display, but I did not find it. I need some help!


texts: How to avoid multiplying of a string which precedes > in code block?

texts:
When <> expands to multiple line and I wrote like this

some-string <<noweb ref>>

then it expands like

some-string line1-from-noweb-ref
some-string line2-from-noweb-ref
some-string line3-from-noweb-ref

Is there a way to avoid this?


texts: Org ASCII export with indentation preserved

texts:
Open your EMACS -Q, enter org mode, and

#+begin_src emacs-lisp

  (setf x '(a b c
              d e f))

#+end_src

This is how it will be aligned after org-edit-special (C-c ').

Now export to an ASCII buffer with C-c C-e t A.   You will see

,----
|
| (setf x '(a b c
|           d e f))
|
`----

Clearly, the indentation has changed.  How does one get
indentation as in the source?

P.S.

This does not happen when exporting to a LaTeX buffer.  It seems
to be a bug resulting from the use of tab characters and the
insertion of two extra characters at the beginning of each source
line.  I suppose plain-text export isn't used that much.


texts:
I have a dired workflow that I like. From a file-visiting buffer, I'll use dired-jump to pop up to the containing directory. Dired renders the directory in a new buffer with the cursor on the file-entry I came from. Another dired-jump puts me in the parent directory with the cursor on the subdirectory I was in. This makes it easy to drill back down with a series of Return keypresses.

The downside is that dired generates a lot of buffers in order to build such a "breadcrumb" trail. I mitigate this somewhat by reusing buffers on my way down, using dired-find-alternate-file. But I still end up with multiple dired buffers littering the buffer list, so I'd like to find an easy way to toggle hiding dired buffers in IBuffer.

As an example, with a file-tree like,

~
├── A
└── B
    ├── x
    └── y

and starting from the file ~/B/y, running dired-jump results in (using | to represent the cursor position):

buffer contents  buffer list
---------------  -----------
~/B:             ~/B/
.                ~/B/y
..
x
y|

Another dired-jump:

buffer contents  buffer list
---------------  -----------
~:               ~/
.                ~/B/
..               ~/B/y
A
B|

Then find-alternate-file:

buffer contents  buffer list
---------------  -----------
~/B:             ~/B/
.                ~/B/y
..
x
y|

And another find-alternate-file puts me back into file y, with only ~/B/y in my buffer list.


texts: Org-mode export to text: exporting citation to plain text

texts:
I am trying to generate text files from org files(originally intended for latex>PDF outputs), for submissions that require plain text.

org-file:

#+TITLE: Foo

#+latex_class: article-no-defaults
#+OPTIONS: |:nil toc:nil author:nil
#+latex_class_options: [11pt,a4paper]
#+latex_header: \usepackage{fontspec}
#+latex_header: \setmainfont{Times New Roman}
#+latex_header: \usepackage{float}
#+latex_header: \usepackage{latexsym}
#+latex_header: \usepackage{graphicx}
#+latex_header: \usepackage{url}
#+latex_header: \usepackage{cleveref}

#+EXPORT_EXCLUDE_TAGS: noexport
#+DRAWERS: NOTES
\date{}
\maketitle

*Document Begins
text text

sentence 1 cite:Ohala1997. sentence 2 cite:Ohala1983, cite:Ham1998. Previous studies on sentence 3 cite:hankamer1988, cite:Ghosh2015, cite:banerjee2018.  sentence 4 cite:recasens1997. sentence 5 cite:banerjee2018.

bibliography:file.bib
bibliographystyle:plain

I tried ‘apalike’ ‘plain’ and ‘natbib’ to check if the problem persisted with different bibliography styles. When I exported this file to text(c-c c-e t U/A) in unicode and ASCII, this was the output:

       ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
           Foo
       ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

\date{} \maketitle

sentence 1 [Ohala1997]. sentence 2 [Ohala1983], [Ham1998]. Previous studies on sentence 3 [hankamer1988], [Ghosh2015], [banerjee2018].  sentence 4 [recasens1997]. sentence 5 [banerjee2018].

Bibliography ============= [Ohala1997] John Ohala, Aerodynamics of
phonology, {Proc. 4th Seoul International Conference on Linguistics
[SICOL]}, (), 92--97 (1997). link. doi.  [Ohala1983] John Ohala, PHONETIC
EXPLANATIONS FOR SOUND PATTERNS: IMPLICATIONS FOR GRAMMARS OF
COMPETENCE., {Historical linguistics: Problems and perspectives},
(), 237--278 (1993). link. doi.

Here, the in-line references are simple the assigned tags, the bibliography has HTML codes, and \date{} \maketitle are also being read as is(this is a problem I’ve seen in Git repos sometimes). Is there a way to generate a text file(templates, packages) with the bibliography section rendered correctly, and without at org-mode tags?

Thanks in advance.


texts:
If I

M-x shell
C-u M-x shell <RET>

I get two buffers, named *shell* and *shell*<2>.

If I switch to another buffer, and I do

C-x b sh <TAB>

The echo area doesn't complete to *shell* (which is unambiguous at this point), it completes to shell*. I then have to

C-a * <RET>

in order to switch to it. I really dislike this. Is there a way to get the former to complete to *shell*, so that I can do

C-x b sh <TAB> <RET> <RET>

Rather than being forced into

C-x b sh <TAB> C-a * <RET>

?

What I'm really after is just an easier way to switch to the buffer named *shell* than the current way, so suggestions here would also be welcome.


texts:
On Emacs 26.3, Ubuntu 20.04, when I run
emacs -Q

followed by
(package-refresh-contents)

I get
Contacting host: elpa.gnu.org:443

So the package refresh just hangs. I tried to switch from https to http, but no luck.


texts:
I have been thinking about setting up a list of my relations. Something to keep track of when we last met, what their food preferences are along with contact information. A normal org file will probably do good as a start, but then I started exploring if others have thought about the same thing.
Around the net I can find references to org-contact. It seems like it used to be distributed separately from org-mode, but is now located in the source tree of org-mode. But running
(require 'org-contacts)

fails even though I have Org mode version 9.3 installed.
My question then is: How do I install org-contacts?


texts: org mode sum time from remote table with org-lookup-all


texts: Issue with characters in buffers being displayed in wrong positions

texts:
I work with Emacs within Docker as my dev environment so that I can have clean dev environments per language or type or projects that I do e.g. PHP dev, NodeJS dev, Haskell dev etc with different software or extensions installed etc.

Since upgrading to the latest version of Docker though (1.8, now 1.9) characters get misplaced, making a mess of the code. This happens when I open a file, or when I type something. This is only a display issue - the characters in the file are actually in the correct place. When I select the messed up lines (Ctrl+Space Ctrl+n or similar) the lines are corrected and properly displayed.

Usually characters get misplaced within the same line, but occasionally characters disappear or are overridden by other characters, or characters that do not belong to the line appear. One pattern that I have seen is that if I jump a page down with Ctrl+v, a line from the new visible part of the buffer gets messed up with the line that was previously there e.g. some of the characters of the 8th line from the bottom are overriden by the characters that where on the same line before jumping down. But there are other cases as well.

Attached are some screenshots that may clarify what happens.

This was not happening before the upgrade (I was using Docker 1.5 I believe, or earlier). The upgrade was part of a system upgrade to Fedora 23, but when I run emacs directly on the host I don't have this issue. The Docker container is based on the Fedora 23 official Docker image.

I'm not sure it is a Docker issue though. I would expect fedora to install all required dependencies when doing "dnf install emacs" since I believe the repositories are the standard Fedora repositories. But since the Fedora Docker image is a very minimal image, is there any package that I may need to install?

Any insights are welcome, my dev environments are kind of unusable at the moment.

Messed up code

Corrected by selection

Messed up code

Corrected by selection

Messed up code

Corrected by selection


texts:
I am using org-gcal and want to sync my Gmail Calender with Emacs. The from Google to Emacs way seems to work really nice.
In addition I am using calfw to view the appointments.

Is there an easy way to create a new appointment with predefined fields, like subject, time and so on, instead of manually create a todo in the gmail org file?

As proposed in the comments here is a sample appointment:

* Title
  :PROPERTIES:
  :LINK: [[https://www.google.com/calendar/event?eid=123456789][Go to gcal web page]]
  :ID: ukf76ifl27j3shea562f5vrhe0
  :END:

  <2016-08-01 Mo 09:10-10:10>

I hope this helps.


texts:
When using (i)ESS, I would like to function/variable/argument/filename completion on demand using the minibuffer, without triggering the company pseudotooltip front end.

I have tried the following:

(setq company-begin-commands nil)
      company-idle-delay nil)

This seems to work fine for all sorts of completion. Except, that when I call a function that has a lot of arguments, emacs becomes very unresponsive. For example, if I type:

print(

and press TAB after the parenthesis, the minibuffer will show, but typing will become nearly impossible (i.e. delay of 2 or 3 seconds between each typed character). Even if I disable company-mode the completion is sluggish so I wonder if this is an issue of ESS? How to solve this?


texts: Not matching a character at the beginning of line

texts:
I would like to match lines that have the phrase a test but not start with >. So I want to match

This is a test
a test this is

but not

> This is a test

I am not sure how to do this without lookahead in emacs.

As a first try I tried^[^>].*a test. However, for some reason, this matches > This is a test when there's a newline before it which I don't understand since the first character in a line should not be >.

What is the correct regular expression for this case? And why is my regular expression matching lines starting with >.


texts: How to keep hl-line updated in inactive window?

texts: I have (setq global-hl-line-sticky-flag t) to enable hl-line in all windows.  However, the highlighted line isn't updated when I change the cursor position in inactive window (e.g., by calling next-error to go to next error in the compilation buffer).


texts: How to search an Arabic word in text without its diacritics/accents?

texts:
In Arabic as with some other languages there is what is called diacritics to enhance pronunciation. There is no convention on how many diacritics should be written for a single word. Some use the minimum (which I prefer) just enough to disambiguate pronunciation, whereas some use them superfluously or just for aesthetic calligraphic purposes. Thus, there is a wide variation on what and how many diacritics are associated with one word. When I do isearch-forward/backward by pressing C-s/r, problem arises when I type it in the search mini-buffer without diacritics it will not match the same word in the text if it had diacritics, making the task of looking for this word with its potential diacritics ever unsatisfactory.

Is there a way to make search/regexp search unaware of diacritics? I hope there would be an answer that can be extended to include regexp C-M-s/r and grep search that I use quite often in helm-projectile to look for a word in a multi-file latex projects.

Update
It would be nice to see that Emacs in all of its search functions doing the stripping off step on the text (from accents/diacritics/you name it) before matching step as a default behavior that might be turned off by a prefix on demand no matter what language is at hand. Typically, when I search for something I don't expect from the best editor (Emacs) to fail in this errand just because of some diacritics or accents that are rarely if ever needed to accomplish mundane text chores.


texts: How to define LaTeX document class for org-mode export (other than default)?

texts:
I want to add to org-latex-classes new class, namely "exam" (as described here: https://www.sharelatex.com/templates/exams/exam), here's a preview of an example document beginning:

\documentclass[12pt]{exam}
\usepackage[utf8]{inputenc}

\usepackage[margin=1in]{geometry}
\usepackage{amsmath,amssymb}
\usepackage{multicol}

\newcommand{\class}{Math I}
\newcommand{\term}{Winter 2014}
\newcommand{\examnum}{Exam 1}
\newcommand{\examdate}{1/1/2014}
\newcommand{\timelimit}{60 Minutes}

\pagestyle{head}
\firstpageheader{}{}{}
\runningheader{\class}{\examnum\ - Page \thepage\ of \numpages}{\examdate}
\runningheadrule

\begin{document}

\noindent
\begin{tabular*}{\textwidth}{l @{\extracolsep{\fill}} r   @{\extracolsep{6pt}} l}
\textbf{\class} & \textbf{Name:} & \makebox[2in]{\hrulefill}\\
\textbf{\term} &&\\
\textbf{\examnum} &&\\
\textbf{\examdate} &&\\
\textbf{Time Limit: \timelimit} & Teaching Assistant & \makebox[2in]{\hrulefill}
\end{tabular*}\\
\rule[2ex]{\textwidth}{2pt}

[...]

\begin{questions}

\question[1] Calculate 2+2.
\addpoints

[...]

I've read answer to this question and documentation for org-latex-classes variable, but I don't understand how to apply given syntax to my case (there are no sections or subsections in "exam", etc.).

I would like to be able to write my exams in org mode where for example new headlines would be different questions, number of points would be handled by property drawers, #+TITLE would be \examnum or \class and #+DATE would be \examdate, etc.

Is it possible? If yes - is there a documentation which shows how to translate org-mode markup into particular LaTeX document markup with more detail than org-latex-classes doc?


texts: How to make org understand a custom timestamp format

texts:
I have the following line below a "TODO":

SCHEDULED: <Oct 27, 2018 08:30PM>

Right now, the org-mode throws the following error:

Error was: (Not a standard Org time string: Oct 27, 2018 08:30PM); Skipping entry

Bad timestamp ‘Oct 27, 2018 08:30PM’


texts: emacs ess apply function to token under point

texts:
I've finally committed to moving over to both emacs and ess -- and i'm having a bit of trouble getting (the famously customisable) combination to work as i'd like.

Say that i have a file that contains an object called rainfall open in emacs and an inferior R session open. Is there a way that i can put point over the token and then send it to the R process for a function to be applied to that object?

To make it concrete, say the source file contains the following object:

rainfall <- xts(runif(100, min = 0, max = 10), seq.Date(as.Date('2019-01-01'), by = 1, length = 100))

I'd like to be able to put point anywhere inside the token rainfall and (via some keyboard shortcut) send it to the R process with some function (such as head, tail, plot, or summary) applied to it.

So in the iESS[R] screen i'd see: R> tail(rainfall) and the associated output.


texts: Autoindent yas-snippets which call up another function

texts:
I use the snippet function_docstring_numpy (shortcut: fdn) in python to define nicely documented functions. They look like this:

def flip(batch):
    """Flip a batch of images
    Works for a single image as well as many images, using the Ellipsis object.

Parameters
----------
images : a numpy array with dimensions (num_images, height, width, num_channels)

Returns
-------
out : an array of identical dimensions to input array, with images flipped

    """
    return images[...,::-1,:]

I really love this snippet, although that (lack of) indentation of the Parameters and Returns sections bothers me.

The snippet (show below) call a Lisp function:

def ${1:name}($2):
    \"\"\"$3
    ${2:$(python-args-to-docstring-numpy)}
    \"\"\"
    $0

I got to the function using C-x h function_docstring_numpy and opening the linked function: python-args-to-docstring-numpy, which looks like this:

(defun python-args-to-docstring-numpy ()
  "return docstring format for the python arguments in yas-text"
  (let* ((args (python-split-args yas-text))
         (format-arg (lambda(arg)
                       (concat (nth 0 arg) " : " (if (nth 1 arg) ", optional") "\n")))
         (formatted-params (mapconcat format-arg args "\n"))
         (formatted-ret (mapconcat format-arg (list (list "out")) "\n")))
    (unless (string= formatted-params "")
      (mapconcat 'identity
                 (list "\nParameters\n----------" formatted-params
                       "Returns\n-------" formatted-ret)
                 "\n"))))

I managed to shift the Returns sections up a line be removing a newline symbol, but my question is:

How can I ensure the entire docstring including Parameters and Returns are indented?


texts: Passing a variable to template function in org-capture-templates

texts:
I'm using org-capture to insert expenses into a Ledger file with this template, along with auto-completion for the various expense categories:

(setq ledger-expense-completions
    (list
     "" ;; needed for first | for mapconcat
     "Expenses:Food" "Expenses:Food:Restaurants" "Expenses:Food:Groceries"
     ))

(setq capture-expense-template
    "%%(org-read-date) * %%^{Description}
  %%^{Expense%s}  %%^{Amount}
  Account:Cash")

(defun return-capture-expense-template ()
    (let ((compstring
        (mapconcat 'identity ledger-expense-completions  "|" )))
            (format capture-expense-template compstring)))

(setq org-capture-templates
    (append '(("l" "Ledger entries")
              ("lc" "Cash" plain
              (file "~/Documents/journal.ledger")
              (function return-capture-expense-template)
              :empty-lines-before 1
              :empty-lines-after 1))
            org-capture-templates))

This works fine, however I'd like to modify return-capture-expense-template to make it a bit more dynamic so that I can pass in the account, e.g., "Account:Bank" or "Account:Cash", to support variations of this template without creating a separate capture-expense-template for each variation.

So here's how I modified things:

(setq ledger-expense-completions
    (list
     "" ;; needed for first | for mapconcat
     "Expenses:Food" "Expenses:Food:Restaurants" "Expenses:Food:Groceries"
     ))

(setq capture-expense-template
    "%%(org-read-date) * %%^{Description}
  %%^{Expense%s}  %%^{Amount}
  %s")

(defun return-capture-expense-template (account)
    (let ((compstring
        (mapconcat 'identity ledger-expense-completions  "|" )))
            (format capture-expense-template compstring account)))

(setq org-capture-templates nil)
(setq org-capture-templates
    (append '(("l" "Ledger entries")
              ("lc" "Cash" plain
              (file "~/Documents/journal.ledger")
              (function return-capture-expense-template "Account:Bank")
              :empty-lines-before 1
              :empty-lines-after 1))
            org-capture-templates))

When I try evaluating (return-capture-expense-template "Account:Bank") on a separate line, that gives me the template output that I would expect (with "Account:Bank" dynamically inserted into the capture template), however when I run org-capture, I get Wrong number of arguments because the "Account:Bank" is not getting passed to return-capture-expense-template on this line: (function return-capture-expense-template "Account:Bank").

I reviewed the docs for Anonymous Functions and tried writing that line in various ways, but nothing I do seems to be working.

Is it not possible to pass a variable to a function when using the special form function?


texts: advice on easy formating of hydra docstring

texts:
so i used to use the auto generation of hydra hints with the
:hint nil and :column 3 argument
i recently find a need to have better control on whats presented in the hint area of some huge hydras i have so im trying to edit and write my own hints. the problem is that it seems VERY tedious to create and maintain this as every time you add an entry all the alignment changes such as in this example

Main                                    Extra Hydras                         Misc
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
[_<f1>_]                                [_e_]                                [_e_]
[__]                                    [_e_]                                [_e_]
[_e_]                                   [_e_]                                [_e_]
[_e_]                                   [_e_]                                [_e_]
[_e_]                                   [_e_]                                [_e_]
[_e_]                                   [_e_]                                [_e_]
[_e_]                                   [_e_]                                [_e_]
[_e_]                                   [_e_]                                [_e_]
[_e_]                                   [_e_]                                [_e_]
[_e_]                                   [_e_]                                [_e_]
[_e_]                                   [_e_]                                [_e_]
[_e_]                                   [_e_]                                [_e_]
[_e_]                                   [_e_]                                [_e_]
[_e_]                                         [_e_]                                [_e_]
[_e_]                                   [_e_]                                [_e_]
[_e_]                                   [_e_]                                [_e_]
[_n_] work on same buffer               [_o_] org edits                      [_e_]
[_k_] Mark ring                                   [_e_]                                [_e_]
[_e_]                                   [_e_]                                [_e_]
[_e_]                                   [_e_]                                [_e_]
[_e_]                                   [_e_]                                [_e_]

^^^^^^^^------------------------------EXTRA Info-------------------------

one can see how adding text after the hints takes everything out of alignment. is there a more reasonable way of creating these nice aligned columns when you edit text and keep them aligned?


texts: Duplicate messages in sent email folder with mu4e

texts:
Using mu4e, I am using SMTP to send emails through my Office 365 server (I don't like it either). When a message is created by mu4e, a file is created in my "Sent" folder, but then the email server creates another email in the same folder leading to duplicate messages on both my local maildir and the remote server when I eventually synchronize.

I resolved the issue somewhat by creating a separate folder for mu4e, "mu4e-Sent", where local messages are moved to once they are sent. This folder is then not synced with the server and I don't have any duplicates there. But I still have duplicates in my local maildir that appear when searching for emails.

Is there a better way to resolve this? Is there perhaps a way to tell mu4e to ignore the local "mu4e-Sent" folder?

Thanks


texts: Lately my documents dissolve into misinterpreted Unicode, for example α becomes \316\261. What could be the cause for that?


texts: org-html-link-org-files-as-html for LaTeX export?

texts:
I am using org-mode to write my labbook. Each experiment is an org-file that is exported to PDF when finished. Currently, I am linking to previous experiments by using the resulting PDF. Is it possible to link to org-files instead and have org-mode convert the link to PDF once exported?

This would make it easier to jump from experiment to experiment inside Emacs and from PDF to PDF once exported.

I am aware that this is done for HTML export. How do I set this up for LaTeX export?


texts:
Ref: https://superuser.com/questions/209394/reversed-terminal-command-line-window

How to solve that ^ problem for eshell?

Such that, typing any command at the command prompt and pressing return, keeps the point on the same line, but sends the command output block down instead of up.


texts: How can I use ggtags as a company-mode backend?

texts:
I'm working on a project that doesn't play nice with clang. It also doesn't play nice with ctags because the TAGS file is ~180 MB and it chokes up whenever I do anything moderately intensive with it.

I have ggtags set up with it brilliantly, however, and I would like to force company to use only ggtags for completion. The documentation for the ggtags package says:

  company can use ggtags as completion source via company-capf which is enabled by default.

but I really have no idea what that means. How can I use the two together?


texts:
First off, a picture of what I see, editing a handlebars file:

My colour theme is base16-grayscale, so that blue is probably hard coded somewhere.

I asked on the web-mode mailing list, but was told to ask here instead.

Can I disable and/or change the colour of this highlighting?


texts: What is the concept behind the default keyboard shortcuts?

texts:
I know that emacs is often critzied because of its shortcuts. But this isn't the intention of that question! I come in peace! ;)

I was using vim for years. And I see a concept behind of the most shortcuts there. e.g. You don't have to move your right hand/fingers away from the basic-position on the keyboard to navigate in your file.

I did the emacs tutorial and couldn't get into it. Why are the shortcuts this way? Even the basic ones. They are hard to remember and hard to press. In my opinion I have to move and combine my fingers in a unnatural way.

It would help me to get deeper into emacs if I would understand the concept behind that keys. It was the same for me in vim. The first time it was damn crazy. But when I understood it everything went nice and easy. ;)
I am looking forward to work with emacs the same way.

Another side question would be why are CTRL and ALT are renamed in emacs? From the viewpoint of a beginner it doesn't help. It just underline the "exoctic" status of that genius piece of software.

btw: I know the evil-mode and that emacs is able to modify nearly everything I want. But that shouldn't be the starting point for a emacs-beginner.


texts: How to delete all whitespace up to the first non-whitespace character?

texts:
I'm looking for an emacs function that will delete all whitespace from the cursor position (including newlines) until the first non-whitespace character.

For example, if my cursor is positioned at the end of the first line:

main(arg1,
     arg2)

The delete function would result in:

main(arg1,arg2)


texts: When I run built-in magit commands, they output to the magit-process buffer. How can I do the same with a custom magit command that generates shell output?


texts: How to prevent backspace from deleting my shell prompt?

texts:
It is a usual shell display:

ME@mycomputer: ~$ echo

When I do backspace several times It becomes:

ME@mycompu

How to prevent the system word from deleting


texts:
If I open a file with, say, 2 lines, then when I call avy-goto-line emacs shows me in the beginning of each line the keybinding to move the cursor over there.

But try it in a bit longer file (I use a file with 160 lines). It will take about 0.5-1 seconds in order to process the command.

Why is avy-goto-line so slow? Any way to improve it or any alternative to it?

Thank you

IMPORTANT EDIT: I can reproduce this when I have 145 lines on the screen (I use a screen in vertical), with fewer lines the process is faster.


texts:
I'm trying to replace SourceTree with Magit and one of the features i can't understand how to reproduce in Emacs is to make it show me remote commits on the graph. In source tree that looks this way:

Is it possible to reproduce in Magit?


texts: How do I auto save evil buffers for specific file types?

texts:
I'm a new Doom Emacs user that can't get used to having to save files manually.
I found a way to auto save evil buffers, but the problem with this approach is that I'm not able step out of vterm (an Emacs terminal emulator) without Emacs prompting me to save the vterm buffer, which obviously doesn't make any sense.
(add-hook 'evil-insert-state-exit-hook
      (lambda ()
        (call-interactively #'save-buffer)))

I was thinking maybe I could save specific file types only, so Emacs doesn't try to save the vterm buffer, how would I modify the above elisp to auto save files only for specific file types?


texts:
Specifically, the keyboard event C-x, following by N z characters, will repeat the previous command N times.

I do not understand how this can work. As far as I understand, after the input event C-x z, for the behavior to be as specified, Emacs would need to somehow remap the z character to the command repeat in order for the next z to actually again execute `repeat'. Is this correct? If so, I do not understand how Emacs can change the keymap immediately after executing a command. If not, what is going on?


texts: Is there a way to make the list of recently clocked-in tasks in org-mode persistent across Emacs restarts and (more importantly) closed buffers? It's annoying having to find the previous task just because I happened to exit a file.


texts:
I would like to use NSTRACE to see its built-in messages, and create new ones, at various locations within nsterm.m.  I imagine/guess that enabling NSTRACE needs to be done when configuring Emacs and it probably requires launching Emacs from the terminal and perhaps an interactive call such as M-x trace-...

Q:  How can I configure Emacs to enable NSTRACE and what other steps are needed to see the messages inside the terminal window?

For example, here is what I would use if I wanted to see the glyph debugging message inside xdisp.c:   I would use --enable-checking='glyphs' when configuring Emacs; then I would launch Emacs from the command line in a terminal; then I would type M-x trace-redisplay and I could see glyph debugging messages inside the terminal that are created inside xdisp.c like this:

#ifdef GLYPH_DEBUG
  debug_method_add (w, "This is my custom message.");
#endif


texts: Force new window to open to the left or right

texts:
I have two frames open with the following window splits:

Frame 1   Frame 2
|---+---+ |------|
|a  |b  | |d     |
|   |   | |      |
|---+---+ |      |
|c      | |      |
|---+---+ |------|

Say that I am in window "a" or "b".  Sometimes when I call a function that needs a window, a new, tiny one "e" will be created instead of using a current one.  This new window is often too small to be of use.

Frame 1   Frame 2
|---+---+ |------|
|a  |b  | |d     |
|   |   | |      |
|---+---+ |      |
|c  |e  | |      |
|---+---+ |------|

How could I open new windows in one of the currently existing vertical windows, "a", "b", or "d"?

I have experienced this issue with at least occur and xref-find-definitions-other-window.

The crux of the issue seems to be with the display-buffer function.  At first glance it seemed like I could use display-buffer-in-side-window to get the behavior I want.  In the case of occur, I came up with

(setq
 display-buffer-alist
 `(("\\*Occur\\*"
    display-buffer-in-side-window
    (side . right)
    (slot . 0)
    (window-width . fit-window-to-buffer))))

This has two problems.

First, it turns out that a side window isn't a window like "b" is to "a".  Instead, it is a 'hidden' window that can be toggled.  For instance, the above code does the following when in window "a", "b", or "c"

Frame 1       Frame 2
|---+---+---| |---|
|a  |b  |e  | |d  |
|   |   |   | |   |
|---+---+   | |   |
|c      |   | |   |
|---+---+---| |---|

and does the following when in "d"

Frame 1   Frame 2
|---+---+ |---|---|
|a  |b  | |d  |e  |
|   |   | |   |   |
|---+---+ |   |   |
|c      | |   |   |
|---+---+ |---|---|

Unfortunately, Frame 2 lives on a vertically aligned monitor and the windows "d" and "e" are too narrow to be convenient.  It's the same kind of problem as before!

The second problem is that it relies on an explicit buffer name.  When using xref-find-definitions-other-window, the buffer name varies.


texts:
Running emacs 25.2.2. Currently I am trying out spacemacs, primarily because I found the keybindings more intuitive.

I needed some stuff from my init.el to move to .spacemacs before I can start using it fully.

I have set a lot of variables set using customize command. I could easily copy these over to .spacemacs. And they are now working as expected.

But there are some defuns and a lot of keyboard macros.

Should I just copy them over to .spacemacs and put them at the end of the file or is there a more formal/ structured/ recommended/ better way of doing it?


texts: Get complete list of symbols in helm-lisp-completion-at-point?

texts:
I often use helm-lisp-completion-at-point to "search" for elisp symbol names. The problem for me is that if I start the completion with

(line|

it filters the completion candidates to symbols beginning with "line". But sometimes I guessed wrong and the symbol does not begin with "line". When I delete the helm input line it will only show the candidates starting with "line".

How can I always get the full list of completion candidates?


texts: How to disable certain org-mode blocks from accidental execution

texts: I have some shell code that can be dangerous to run on local machine in a org-mode source code block. Globally, I have configured org-mode to prompt for execution, but I would still like to make sure that these blocks will NEVER be executed with per-block configuration.


texts: How can i add more sources to helm-find-files?

texts:
I want C-x C-f which is mapped to helm-find-files to include

X amount of recently opened files
Files in the X number of unique directories as recently opened files
Files in recent projects, ie git, svn projects e.g helm-projectile
A manually configured list of directories

I don't know how to go about it and I came across an example from this blog

Following an example at http://blog.jenkster.com/2013/10/finding-files-in-emacs-helm.html

(helm :sources '(helm-source-findutils
                 helm-source-ls-git
                 helm-source-locate)
      :buffer "*helm-find-files*")

If I want to accomplish do I need some additional source which be
add to the list above? How will they be implemented?

If it is not possible with helm what other package can accomplish this?


texts: How to bind "control b" (that is b pressed after control not with it) to buffer-menu?

texts:
(define-key evil-normal-state-map (kbd "C b") 'buffer-menu)

This obviously gives Key sequence starts with non-prefix key
But I don't know what I need to unset to make it work.


texts: How do I align a block of text into columns?

texts:
For instance, let's say I have the following block of code in a buffer:

pattern TTF_STYLE_NORMAL = #{const TTF_STYLE_NORMAL}
pattern TTF_STYLE_BOLD = #{const TTF_STYLE_BOLD}
pattern TTF_STYLE_ITALIC = #{const TTF_STYLE_ITALIC}
pattern TTF_STYLE_STRIKETHROUGH = #{const TTF_STYLE_STRIKETHROUGH}

I want to convert it into:

pattern TTF_STYLE_NORMAL        = #{const TTF_STYLE_NORMAL}
pattern TTF_STYLE_BOLD          = #{const TTF_STYLE_BOLD}
pattern TTF_STYLE_ITALIC        = #{const TTF_STYLE_ITALIC}
pattern TTF_STYLE_STRIKETHROUGH = #{const TTF_STYLE_STRIKETHROUGH}

I need some way of saying align this block into columns divided by the = character. Ideally, I'd like to be able to do the same thing with multiple delimiter characters, like splitting on a ->.

How could I accomplish this?

If there's a minor mode for it - great! Code samples welcome also.

Thanks!


texts: How to prevent Emacs from breaking hard links?

texts:
Let's say I have two files file1 and file2:

$ echo aaa >file1
$ ln file1 file2

Then I check that the inodes are the same:

$ ls -i
18749779 file1  18749779 file2

which shows that the two files are actually the same. Now I edit file1 in Emacs, and add a line with for example the text bbb, and save it and exit Emacs.

Now I get:

$ ls -i
18749781 file1  18749779 file2
$ cat file1
aaa
bbb
$ cat file2
aaa

So the hard link is broken. Note that this does not happen when I edit the file in vim, or if I simply do echo bbb >>file1..

How can I prevent Emacs from breaking hard links?

Update:

Note that I have

(require 'backup-dir)
(setq bkup-backup-directory-info
      '((t  "~/.emacs-backups/" ok-create full-path )))

in my ~/.emacs init file. If I edit file1 using emacs -Q file1 instead, I get a file called file1~ in the current directory that links to file2 (has the same inode) but the file1~ has not been modified (so it is identical to the old file1).. This is not what I desire. I would like both file1 and file2 to be the same file, and to include the updated file contents..


texts:
Is there support for Critical Markdown in org-mode or in Emacs text editing in general?
I am interested in MSWord style track-changes in plain text, and learned that Critical Markdown fits the bill. On their website, they listed a number of supporting editors such as a BBEdit Plugin and a Sublime Text Plugin.
Is there a similar mode in Emacs for this?


texts: Pick a window for ido-find-file-other-window and ido-switch-buffer-other-window

texts:
Thanks to @itsjeyd, I've come to love ace-window, but now I want more.

I use C-x 4 f and C-x 4 b to invoke the commands ido-find-file-other-window and ido-switch-buffer-other-window, but I want to pick the window to be used.  That is, I want to use ido to pick the file or buffer name and (probably) something like ace-window to select the window to be used.

Today, I have to:

Invoke ace-window to select the window I want to change.
Invoke ido-find-file or ido-switch-to-buffer.
Invoke ace-window to go back to the original window.

Is there a better way?  If not, I will likely try to write something to do what I want and put it on github.


texts: More than two variable for equality predicates?

texts:
I see that = is great for "comparing" more than two (numerical) arguments, e.g., (= 1 1 1). But then eq, eql, and equal all only allow two arguments. And nesting is nonsense, i.e., the inner eq returns only nil or t to compare the next argument. Any way to get more than two things (non-number) compared with a comparison predicate? For example:

(= (+ (* constant input-1) input-2)
   (+ (* constant input-2) input-1)
   (* constant output))

This, BTW, is a definition of a linear system. But then it's awkward to not be able to directly compare more than two conditions at a time.


texts: Scheduling in Org mode without using mouse or track pad

texts:
I'm scheduling items according to instructions here: https://orgmode.org/manual/Inserting-deadline_002fschedule.html#Inserting-deadline_002fschedule
I have pain in my hands that is exacerbated especially by using pointing devices such as a mouse or track pad. I can still tolerate typing pretty well. So far, Org-mode is the least mouse intensive organization tool I've found.
It looks like scheduling will require some mouse or track pad use. (ouch!) It looks like there isn't any way to specify a date in the future (after entering C-c C-s) other than with a pointing device or touch screen. I could make the touch screen work, but I'd prefer to keep my hands on the key board.


texts: How to set window size programmatically (and without guesswork)?

texts:
When searching for how to set an Emacs window size programmatically, all I can find are recipes that include statements like

(add-to-list 'default-frame-alist
     (cons 'height (/ (- (x-display-pixel-height) 100)
                         (frame-char-height))))

In this operation, the target height (in number of lines) is computed, roughly speaking, by dividing the total height (in pixels) by the height of a single line (in pixels).

In fact, it's not the total height that gets divided, but rather the total height minus some "fudge factor" (in this case 100 pixels).

This subtraction of a "fudge factor" is a sad little ploy to get some information (namely, the available display height in pixels) that Emacs surely must already have.  Doesn't it?

IOW, isn't there a programmatic way to achieve this effect that does not require guessing such "fudge factors"?


texts: How to use company-transform to uppercase SQL keywords

texts:
company-transform seems can be used to apply function on candidates.
How to uppercase all SQL keywords which are in company complete candidates?

only apply this transform function in SQL/NoSQL buffers, like some modes: redis, edbi, etc.
use SQL keywords resource from somewhere like sqlup-mode.
show uppercased SQL keywords candidates in company popup menu.


texts:
I am trying to set up org-mode babel to work with MAGMA.  What I have so far is very simple but works well enough.  The problem is that it does not support sessions, which would be quite important to me.
Here is what I have so far:
  ;;; ob-magma.el --- org-babel functions for magma evaluation

  ;;; Requirements:

  ;;; Code:
  (require 'ob)
  (require 'ob-ref)
  (require 'ob-comint)
  (require 'ob-eval)
  (require 'magma-mode)

  (defun org-babel-execute:magma (body params)
    "Execute a block of Magma code with org-babel."
    (let ((in-file (org-babel-temp-file "n" ".m")))
      (with-temp-file in-file
        (insert body))
      (org-babel-eval
       (format "magma -b %s"
               (org-babel-process-file-name in-file))
       "")))

  (provide 'ob-magma)

  ;;; ob-magma.el ends here

How can I add session support?


texts: org-mode: Something like bytefield package

texts: Is there a way to generate data structure overviews like the bytefield package for latex with plain tables? (I.e. I don't want to fall back to LaTeX)


texts: Coding issue with clang-format on Windows

texts:
After a recent Emacs update, the clang-format package started to misbehave under Windows. For instance, calling clang-format-buffer on a test.cpp file with the following content returns error:

"(clang-format failed with code 1: error: invalid length 34, offset + length (34) is outside the file.)"

{
  int a = 2;
  int b = 1;
}

It seems that the length passed to clang-format is right, because putting Point at the end of the buffer and calling (bufferpos-to-filepos (point)) returns 34. The file uses DOS-style file endings. But the error seems to be that call-process-region passes \n line endings to clang-format instead of \r\n.

The documentation of clang-process-region states:

  The input sent to a subprocess by call-process-region is encoded using a coding system, much like text written into a file.

buffer-file-coding-system in the buffer is undecided-dos. Is it normal then that call-process-region passes \n instead or \r\n to clang-format?

The clang-format package I tried is installed from melpa.org, version 20161004.253.


texts: How can I keep the TeX-error-overview buffer automatically being updated in particular frame in AUCTeX?

texts: TeX-error-overview provides a nice overview of errors when compiling a TeX document, however the buffer does not get reused when calling it a second time. Moreover, it would be nice if it would automatically show up. How can I achieve that?


texts:
I have the following checklist in org-mode:

* Delete data for problem days [0/4]
- [ ] task 1
- [ ] task 2
- [ ] task 3
- [ ] task 4

Is there a command for quickly tagging one of these items as done? I'd like to end up with

* Delete data for problem days [1/4]
- [X] task 1
- [ ] task 2
- [ ] task 3
- [ ] task 4


texts: I have a problem with org-mode's agenda view. While I've set org-agenda-files to '("~/org/") invariably when I finally spin up M-x org-agenda I find that org-agenda-files just points to one org-file. Obviously something is deciding just to include the last org-file I viewed but I'm having trouble working out what. Is there any way to trap when this variable is changed and display or log some sort of backtrace?


texts:
How do you stage a hunk into git from ediff?

I'd like to be able to view a side-by-side diff and stage hunks into the "HEAD" side of the diff, but that buffer (i.e., spacemacs.~master~) is read-only. Ideally, I could also edit that staged file (to achieve the precision I'd get from editing a hunk from git command-line).

It looks like I can invoke magit status (M-x magit-status), expand a diff (TAB), and use s to stage a diff hunk, but I'd like to do this on a file-by-file basis and from a side-by-side diff.

I'm hoping to replicate the behavior of vim-fugitive.


texts: How do I set up all the fonts in my GUI Emacs

texts:
I have the following in my init.el:

(add-to-list 'default-frame-alist
             '(font . "Monaco-10"))

The above does the job, but Emacs uses some other fonts when displaying headlines in org files or words enclosed in ‘’ quotes in Emacs info (C-h i). I would like to have a way to set up those fonts myself as well. Is there a way?

Here is an image denoting the different fonts used for different parts. You can see that the fonts used for the headline and the fonts used for text between ‘’ quotes (denoted by pink highlight) are different than the default Monaco font used otherwise. It's pretty easy to see the differences, I hope.


texts:
In general, I dislike frames. Right now, I'm using

(setq ediff-window-setup-function #'ediff-setup-windows-plain)

To ensure that ediff does not create a frame when it starts.

However, certain commands, like ediff-show-registry still open up new frames.

Is there any way I can completely disable the creation of frames in ediff?


texts: When M-x desktop-read, theme elements incorrectly restored / displayed: previous theme saved into desktop file?

texts:
I'm a new Emacs user, and I've come across a quirk:

I use a light theme during the day, and I've configured theme-changer to switch to a dark theme after sundown; it works wonders.

However, when I quit Emacs, it saves my desktop session (open buffers, etc.), including the theme that was active during the session.

When I invoke M-x desktop-read, the previous session is restored, but theme elements aren't correctly displayed.
Example: light theme elements, saved with the session, mixed with dark theme (active later when restoring dession).

Example:

Restored session using M-x desktop-read: dark-theme is currently ON, session was saved using light-theme

Restored session, using dark-theme: expected behavior

Does anybody know a way to tell Emacs not save the active theme in the desktop file, or to load everything but the theme active at that time, so that the current theme prevails?


texts: If I am in a comment (including empty lines), how do I get to the beginning of the comment?

texts:
I have the following problem:

I am in a comment or the empty lines after or within the comment. I want to get to the first line of the comment.

So no matter where I am in this commented block, I want to get to the beginning of line ;; blah blah.

M-x butterfly

;; blah blah

;; spoon

;; blah blah blah

;; swordfish

I think I have solved it, albeit clumsily:

(defun beginning-of-comment ()
      (interactive)
      (while
          (progn
            (beginning-of-line)
            (looking-at (rx-to-string (or
              `(: line-start (zero-or-more whitespace) (one-or-more ,comment-start))
              `(: line-start (zero-or-more whitespace) line-end))))))
      (previous-line))

Problem is, I cannot use the solution above, because it makes my emacs crash (and would presumably make other's emacs' with the same OS/emacs version crash too if I were to PR it).

There must be a more idiomatic, less verbose way to get to the beginning of a comment from within it.

Ninja edit: I thought of one more, but this also crashes emacs (becomes totally unresponsive):

(defun testing ()
  (interactive)
  (while (comment-forward) (progn (previous-line) (previous-line)))

Ps. I want this to work in as many modes as possible, so please use comment-start, do not hardcode the comment variable.


texts:
I am on MacOS and using Emacs 26.3

When I go to package-install in the minibuffer and type in flycheck, it autocompletes and adds a hyphen. I can't install just flycheck. Also when I go to list-packages, flycheck is missing. I have refreshed packages and I followed the installation instructions on flycheck.org exactly, and I am using melpa. I attached a picture:


texts: I'd like to apply e.g. widen to all active buffers, rather than the current one.  How can I do this?


texts: ESS installation does not initialize flymake

texts:
I install ESS following these directions, adding these to ~/.emacs:

(require 'package)
(add-to-list 'package-archives
             '("melpa-stable" . "https://stable.melpa.org/packages/"))
(add-to-list 'package-archives
             '("melpa" . "http://melpa.org/packages/"))
(package-initialize)

then typing M-x package-install RET ess RET, and adding this to ~/.emacs as well:

(require 'ess-site)

Now when I open an R file in Emacs, I get this message in a buffer:

Warning (flymake): Disabling backend ess-r-flymake because (error Cannot find program ’R’)
Warning (flymake): Disabling backend flymake-proc-legacy-flymake because (error Can’t find a suitable init function)
Warning (flymake): Disabling backend ess-r-flymake because (error Cannot find program ’R’)
Warning (flymake): Disabling backend flymake-proc-legacy-flymake because (error Can’t find a suitable init function)

and typing in the buffer with the R file is slower because of warnings from Flymake.

I have also set the inferior R program as in this thread:

(setq inferior-ess-r-program "R")

But the result is the same.

How can I fix this?


texts: do not insert space after abbreviation if there's a space already there

texts:
I would like expand-abbrev to operate differently depending on what is just after the abbreviation to be expanded.  In particular, if there is a space after the cursor, then expand-abbrev should not insert an additional space.

For example (assuming | is the cursor, _ is a space, a expands into alpha, and a space is typed):

insertion at the end of line:          a|      --> alpha_
insertion in the middle of a sentence: a| beta --> alpha_beta (not alpha__beta)


texts:
I create my widget with the following code:

(widget-create 'editable-list
                   :entry-format "%i %d %v"
                   :value '("")
                   '(editable-field
                     :valid-regexp "\\(?:ftp://\\|http\\(?:s?://\\)\\|magnet:\\)"
                     :error "Url does not match supported type."
                     :value ""))

Unfortunately input validation is not working.
How does one define a widget of type editable-list with validation?


texts:
I switched to emacs as my C++ ide. I am using irony mode, company, rtags, and since all of my projects are using cmake, cmake-ide.
I cant realy find something online on how the workflow works with cmake-ide?
How can I compile targets and run the resulting binarys using cmake-ide?
Currently I am doing this in terminal mode inside emacs, but I hope I can do this using cmake-ide.


texts: flycheck how to silence certain errors or alternatively how to show warnings when errors are present

texts:
mac osx catalina (latest)
emacs 26.3 from homebrew
flycheck
gfortran 9.3.0

I am trying to use flycheck to clean up and reorganize some code.  Right now I would like to see some warnings to clean them up, but there are some "errors" that flycheck is marking that I don't want to change at this point (also not sure how)
See the example screenshots below.
When an error about a gnu-extension is highlighted, flycheck will not show me where the unused variables are.  I'd like to either silence some errors, or alternatively just have flycheck show me the warnings about the unused variables.
How can I do that
Pic 1: showing the extension error but not the unused variable

Pic 2: showing the unused variable after extension use is commented out


texts: How do I get flyspell to ignore pandoc citations in markdown

texts:
Flyspell regularly shows pandoc citations as a spelling error in markdown documents. For example @chu2017 will come up as a spelling error for 'chu'.

How can I get Flyspell ignore the citations and only check other words in the document?


texts: How to run several programs one after another asynchronously

texts:
I want to run several programs one after another and display their output in a single buffer. I can do this by calling call-process multiple times:

(call-process "cmd1" nil "*out*" t)
(call-process "cmd2" nil "*out*" t)
...

The problem is that Emacs freezes until the last call-process finishes.

How to execute several programs sequentially (one after another) without freezing Emacs?


texts: Is there a general way to delay computing & displaying mode-line text?

texts:
Some things I'd like to show in the mode-line are quite expensive to compute, so I'd rather use an idle timer.
Is there a general way to do this? or does this need to be added individually? (using a method similar to which-function-mode, for example).


texts: AUCTeX previews are not displayed correctly with beamer

texts:
I am working on a beamer presentation with AUCTeX on OS X. When I use preview (C-c C-p C-b) on the following document the equation is displayed right after \end{frame} and not in the line of the equation. When I use \documentclass{article} the equation is displayed correctly.

\documentclass{beamer}
\begin{document}
\begin{frame}
\begin{equation}
a^2 + b^2 = c^2
\end{equation}
\end{frame}
\end{document}

How can I get Preview-Latex to work with beamer?


texts: Can I stop Emacs from resetting default-directory every time I open a file?

texts:
If I:

Start Emacs in my home directory (~)
Find a file in the ~/Projects/ruby-play directory with C-x C-f
Try to find another file with C-x C-f

The default directory in the file finder will be ~/Projects/ruby-play.

What I'd like to see is the default directory being ~ still.

Thank you very much!

P. S. Can I maybe use some external package for it? Will Projectile do it for me, for instance?

P. P. S. Since, apparently, I wasn't clear enough... I don't want Emacs to return to my home directory every time. I wish to preserve any directory I need (e. g., if I start Emacs in the Project directory, I want the file finder to start in the Project directory as well).


texts: immediately invoke string-rectangle upon rectangle-mark-mode selection

texts:
A common use-case that I have is to add a string to the same position of each line of text.

For example, I might start with

expect(one).toEqual(true);
expect(two).toEqual(false);

which I want to transform into

expect(oneValue).toEqual(true);
expect(twoValue).toEqual(false);

What I currently do is:

place my cursor after one
press C-x <SPC> (invoking rectangle-mark-mode)
press C-n to extend the zero-width rectangle down one row
(look up the keystrokes and then) press C-x r t Value <RET> to invoke string-rectangle, thereby adding the string Value to the desired locations

I would like to simply start typing after selecting a rectangle with rectangle-mark-mode, and the rectangular selection would be interactively replaced with what I'm typing (including the case where I've marked a zero-width rectangle). In other words, I want to eliminate the C-x r t step above and just start typing Value immediately. How can I accomplish this?

I'm also curious why this isn't the default behavior of Emacs, since I can't think of a disadvantage to this approach.


texts: Use Elisp macro instead of two function arguments?

texts:
Is the following sort of shortcut macro possible to implement?

(defmacro region-end-beg ()
 "Replacement for '(region-end) (region-begin)' in source code"
 (...))

So that

(buffer-substring  (region-end-beg))
(setq region-length (- (region-end-beg))

Can be used as a shortcut for

(buffer-substring  (region-end) (region-beginning))
(setq region-length (- (region-end) (region-beginning))

This example is semi-contrived.  What I'm interested in is there is a general technique to make this kind of macro in lisp (particularly elisp).


texts: I currently have this in my init file (key-chord-define-global "xf" 'find-file). Actually, xf and fx will trigger the find-file function. In fact, whatever the keychord I defined, it works whatever the order in which keys are pressed. So, just want to know if this is a normal behaviour, and if there is there a way to avoid fx to be considered as a keychord.


texts: How to have desktop-mode restore only the  most recently used buffers

texts:
I currently have in my config:

(desktop-save-mode 1)
(setq desktop-restore-eager 10)

Which on startup, will eagerly restore 10 buffers, and then when Emacs is idle,
restore all the others.

Is there a way I can tell Emacs "I want you to restore the most recently used 10
buffers, and then don't restore any others"?

Right now it seems like the options are either eagerly restoring every buffer,
or eagerly restoring a subset and then lazily restoring every other buffer.


texts: Is it necessary for me to use `cl-labels` in this grouping function, when plain recursion does the job as well?

texts:
So I'm reading through some tutorials with Common Lisp, and I came across this function, group:

(defun group (source n)
  (if (zerop n) (error "zero length"))
  (labels ((rec (source acc)
             (let ((rest (nthcdr n source)))
               (if (consp rest)
                   (rec rest (cons
                               (subseq source 0 n)
                               acc))
                   (nreverse
                     (cons source acc))))))
    (if source (rec source nil) nil)))

After some futzing around, trying to understand what this does (it basically takes a flat list, recurses through it, and then groups them into groups of GROUP-SIZE), I've come up with two alternatives.

This is the version that uses cl-labels, and is basically a straight-up translation of the above group function (along with some additional modifications):

(defun *hx/group-label (sources group-size)
  (if (> 0 group-size)
      (error "Invalid GROUP-SIZE %d: GROUP-SIZE must be greater than zero." group-size)
    (cl-labels ((rec (source accumulator)
                     (let ((others (nthcdr group-size source)))
                       (if (consp others)
                           (rec others (cons
                                        (subseq source 0 group-size)
                                        accumulator))
                         (nreverse
                          (cons source accumulator))))))
      (if sources
          (rec sources nil)
        nil))))

But then I realized... hang on, why do I need to use cl-labels? And so I came up with this version:

(defun *hx/group-recurse (sources group-size &optional accumulator)
  (if (> 0 group-size)
      (error "Invalid GROUP-SIZE %d: GROUP-SIZE must be greater than zero." group-size)
    (let ((others (nthcdr group-size sources)))
      (if (consp others)
          (*hx/group-recurse others group-size (cons
                                                (subseq sources 0 group-size)
                                                accumulator))
        (nreverse
         (cons sources accumulator))))))

What I'd like to know, however, is why it would be necessary to use cl-labels? I'm already using -*- lexical-binding: t -*-, so I don't see the advantages in terms of lexical scope (which cl-labels does, according to the documentation), and they both appear to be functionally similar.

But then again, going through the questions that this query comes up, I'm seeing advice that tells me to not recurse when loops will do. What would be the best way to do this, then?

FWIW, I'm planning to use this function to turn something like this in my init file:

(add-hook 'text-mode-hook (lambda ()
                            (visual-line-mode t)))
(add-hook 'prog-mode-hook (lambda ()
                            (visual-line-mode t)))
(add-hook 'visual-line-mode-hook #'visual-fill-column-mode)
(add-hook 'Info-mode-hook (lambda ()
                                   (setq visual-fill-column-width 80)
                                   (visual-fill-column-mode)))

Into something a little more concise, like:

(add-multiple-hooks (<group-function> (prog-mode-hook <function-def>
                                       text-mode-hook <function-def>
                                       ...)))

Anyone's insights on this would be highly appreciated!


texts: Emacs mark and copy/move to buffers or bookmarked directories

texts:
Is there a way to use bookmarks or the buffer list of open buffers to
efficiently copy/move marked files/directories to another directory?

As an example, imagine I want to copy the files foo.txt and bar.txt
from existing location to a bookmarked directory.

The image above shows the result after marking the two files in dired
and then hitting C.

At this point, emacs suggests the current directory as the destination for copying.

I would like to be able to quickly choose an alternative destination
from within the mini-buffer:

a bookmarked directory
a directory from the current buffer list

So, once I have marked files, hit C, and am in the mini-buffer,
ideally it would be possible to either:

invoke bookmark jump to quickly save marked files to a bookmarked
directory
invoke something (?) to quickly select a directory from the current
buffer list and then save marked files to that directory

I know I can impact the default destination directory by splitting the window and having the desired destination directory visible, but that seems like additional steps that shouldn't be necessary.

I currently use ivy/counsel/swiper, and thought that it might be
possible with that, but haven't been able to find a solution.

I would prefer a solution based on ivy/counsel/swiper, but am open to
other solutions that make use of dired or dired+ (e.g, ido, icicles).
I'm not interested in solutions that involve alternatives to dired or dired+ (e.g., dropping to a shell, ranger, midnight commander).

Unfortunately, I don't have the skills to write something like this
myself, so I'm hoping there is an existing solution. This seems like
the kind of thing that many emacs users would want to be able to do,
so I'm surprised my searches didn't turn up anything.