texts:
I'm using (server-start) in my init.el, but I'd like to be able to launch multiple server instances, every time I launch emacs.

Today, server-start complains if the server is already launched.

It would be nice that if the server already exists, a new server name is automatically determined (like server2, server3), a new server instance launched, and the server name displayed in a message.

As I'm emacs lisp newbie, can someone please help scripting this in init.el?  How to determine if serverN is already launched? List /tmp/emacs$UID?


texts: How can I get an outline in org-beamer export without changing the other frames?

texts:
I have this org-beamer example:
#+TITLE:      Example
#+LANGUAGE:   en
#+SELECT_TAGS: export
#+EXCLUDE_TAGS: noexport
#+CREATOR: Emacs 26.3 (Org mode 9.1.9)
#+STARTUP: beamer
#+BEAMER_FRAME_LEVEL: 2
#+COLUMNS: %40ITEM %10BEAMER_env(Env) %9BEAMER_envargs(Env Args) %4BEAMER_col(Col) %10BEAMER_extra(Extra)
#+OPTIONS:   num:t toc:t \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
#+OPTIONS:   TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:not-in-toc

* Section

** Frame
   Pellentesque condimentum, magna ut suscipit hendrerit, ipsum augue ornare nulla, non luctus diam neque sit amet urna.

* Other Section

** Other Frame
   Nullam rutrum.

* Third Section

** Third Frame
   Pellentesque tristique imperdiet tortor.

It does what - almost. The "normal" pages look like this:

But: the Outline is empty. I found that I can add an outline for the 2nd level org items with the option #+OPTIONS: H:2. With that option, I get an outline, but now the pages look like this:

Is there a way to get both?


texts: Are there other ways of introducing local variables other than `let`

texts:
I am new to Emacs-Lisp and I was surprised to learn a curious variable scoping rule in Emacs that any variables which are intended to be used locally must be explicitly declared with let. Otherwise variables set with setq get global scope. to be precise here is some code.

e.g.

;; outside this function foo1 and bar1
;; don't exist.
(defun add1 ()
  (let ((foo1 1) (bar1 4))
    (+ foo1 bar1)))

;; but here without the let-statements the
;; variables persist!
(defun add2()
  (setq foo2 1)
  (setq bar2 4)
  (+ foo2 bar2)
  )

(add1)
(add2)

;; now if I try evaluating the following
foo1 ;; will give error (symbols value as variable is void)
bar1 ;; ditto

foo2 ;; will print 1
bar2 ;; will print 4

Just to be sure, I would like to know if let is the only way of creating
local variables in Elisp code.

Edit: Hmm this seems to be the behavior with Common Lisp too, after running it past my clisp compiler i.e. foo2 and bar2 continue to persist
outside the scope of add2


texts: modify syntax table for strings in perl modes

texts:
My company uses a version of Perl where you can define by binary number using something like my $var = 'b010110110; etc. Problem is both perl-mode and cperl-mode interpret ' as the start of the string and will apply a string font lock to everything until the next '. This causes large sections of code are to appear as a string when they are not.

I have looked into how Emacs defines strings, and it does not have a string start or string end  syntax class. Rather it just has a string quote character syntax class of which both " and ' are members of in Perl modes.

I have modified the syntax table to changed the ' character from the string quote character class to the punctuation character class. This fixes the problems of stringifying blocks of code but normal strings quoted with ' are no longer recognized.

I need a really smart person who can show me some code to modify the syntax highlighting of Perl so that strings are recognized as strings and binary notation is recognized as binary notation. How can I accomplish this?


texts:
A couple of questions related to mail archives: (1) what should the "elmo archive" that the manual refers to look like internally? Have not been able to find anything about this in google. (2) I have zip files containing what seems to be Maildirs, and have lines like this in .folders:

$name;zip;topdirectory

But when I open Wanderlust, it says this does not exist and should it be created. Have not experimented further, as I am clearly not able to express what I mean in the config file. Can Wanderlust handle Maildir inside zip? Also, (3) does anybody know a practical way to convert Outlook .pst files into something Wanderlust can understand? Have tried some tools (readpst, mb2md I think) but got lots of garbage (empty directories with strange names etc) and could not get Wanderlust to open any of the files.

Is "mbox" and Wanderlust "news spool" the same thing?


texts: How to give attribution to Creative Commons pictures in org-mode

texts:
I am making a presentation in org-mode and have some creative commons pictures that I need to give attribution for.

I have tried using a footnote with the reference but as the picture is in the right column of a two column slide, the reference just runs off the slide and looks messy.

Does anyone have a method that they use in org-mode that gives attribution in a neat and clear way?


texts: How do I create a snippet that optiionally expands multiple lines using YASnippet(or some other tool)?

texts:
I know how to create basic snippets using YASnippet.
For example, consider the following snippet:
# -*- mode: snippet -*-
# name: js-function
# key: jsfunc
# --
/** @function
 * @name ${1:fn-name}
 * @description ${2:description}
 * @param  {${3:type}} ${4:name} ${5:desc}
 * @returns {${6:type}} ${7:desc}
 */

const $1 = exports.$1 = ($4) => {

};

This works very well, as intended.
I would like to do the following two more things:

Keep the number of @params dynamic, and have YASnippet use the tab-stop fields 'type', 'name' and 'description' for each, and then mirroring the 'name'(s) in a comma separated list (using mirrored field transformations perhaps?).
I know YASnippet supports embedded elisp, but since I am a noob, I can't really figure out if there is some obvious way to do this using elisp.

Automatically insert a '* ' for every line automatically if I insert a multi-line ${2:description} This could in theory be implemented easily if the above functionality is possible. I am currently doing this by M+q`, however it would be nice if this can be done using YASnippet

Following expanded code is what I would like to achieve dynamically:
/** @function
 * @name generateDSAKey
 * @description Generate a DSA Keypair
 * @param  {int} keysize keysize of the DSA
 * @param {function} cb callback function
 * @returns {undefined}
 */

const generateDSAKey = exports.generateDSAKey = (keysize, cb) => {

};

Any help in this regard is much appreciated


texts:
I interact with the Gnu Octave's inferior mode and everything seems to be working fine there:
octave> pkg load symbolic
octave> syms x
g = (x+1)/sqrt(x^2 - 1)
simplify(diff(g,x))
octave> g = (sym)

     x + 1
  ───────────
     ________
    ╱  2
  ╲╱  x  - 1

octave> ans = (sym)

          -1
  ───────────────────
             ________
            ╱  2
  (x - 1)⋅╲╱  x  - 1

Now I do the same using org mode and babel where I get an error:
#+begin_src octave :session :eval never-export :results verbatim
pkg load symbolic
syms x
g = (x+1)/sqrt(x^2 - 1)
ans = simplify(diff(g,x))
#+end_src

And when I evaluate the above code, I see the following error in the inferior mode's octave session:
octave> > > error: fprintf: wrong type argument 'class'
error: called from
    dlmwrite at line 195 column 7

Any idea on what I'm doing wrong ?


texts: Find files with find-dired sorting by date and by size

texts:
I often use find-dired and find-named-dired.
But I wanted to get the results sorted by date and by size.

How can I do that?


texts: After quite some hacking I now longer get a warning from a package, did I have success? How do I list all loaded packages? (NOT INSTALLED, installation was not the problem, loading was, eg require).


texts: Org mode agenda fails to show consistency graph

texts:
I set up the Org mode consistency graph of habits following the manual. Each habit is, e.g.:

** TODO some habit
SCHEDULED: <2019-12-22 Sun 07:20 ++1d>
:PROPERTIES:
:STYLE: habit
:LAST_REPEAT: [2019-12-21 Sat 09:14]
:END:
:LOGBOOK:
- State "DONE"       from "TODO"       [2019-12-21 Sat 09:14]
...
:END:

and my init file has:

;; track habits
(add-to-list 'org-modules 'habits)
(setq org-habit-graph-column 65)
(setq org-habit-show-habits-only-for-today nil)

The consistency graph showed in agenda view for the week yesterday and I cannot replicate it now, either in view for the week or the day. I tried adding the code from How to show org-habit graph alone?

(set 'org-habit-show-all-today t)

Pressing K in either day or week view shows that the buffer is read-only in the mini-buffer.

How can I set up the consistency graph or debug what's wrong?


texts: Why (lambda () (run-hooks 'foo)) instead of just 'foo?

texts:
I am studying the following code snippet taken from prelude-c.el:

;; taken from prelude-c.el

(defun prelude-makefile-mode-defaults ()
  (whitespace-toggle-options '(tabs))
  (setq indent-tabs-mode t))

(setq prelude-makefile-mode-hook 'prelude-makefile-mode-defaults)

(add-hook 'makefile-mode-hook (lambda ()
                                (run-hooks 'prelude-makefile-mode-hook)))

The author defined a function named prelude-makefile-mode-defaults, then made prelude-makefile-mode-hook an alias to it, and finally run it with lambda and run-hooks. This looks tedious to me. In my humble opinion, it can be simplified to

(defun prelude-makefile-mode-defaults ()
  (whitespace-toggle-options '(tabs))
  (setq indent-tabs-mode t))

(add-hook 'makefile-mode-hook #'prelude-makefile-mode-defaults)

Now it is much clearer, and they appears to have the same effect, but of course, the authors of prelude.el must be much more sophisticated than me, who is just a beginner. Is there any hidden advantage of writing down all these seemingly redundant code?


texts: ansi-term - wrong type argument: characterp, return

texts:
When using ansi-term on Emacs a get the following error whenever I press enter in char-mode:

wrong type argument: characterp, return

I used toggle-debug-on-error and get the following:

Debugger entered--Lisp error: (wrong-type-argument characterp return)
  string(return)
  term-send-raw()
  call-interactively(term-send-raw)
  (let ((cua-delete-selection (not autopair-autowrap)) (blink-matching-paren (not autopair-action))) (call-interactively beyond-autopair))
  (let* ((autopair-emulation-alist nil) (beyond-cua (let ((cua--keymap-alist nil)) (autopair-original-binding fallback-keys))) (beyond-autopair (autopair-original-binding fallback-keys))) (if autopair-autowrap (progn (setq autopair-wrap-action (autopair-calculate-wrap-action)))) (setq this-autopair-command this-command) (setq this-original-command beyond-cua) (if (and (featurep (quote paredit)) (symbolp beyond-cua) (string-match "paredit" (symbol-name beyond-cua))) (progn (setq autopair-action nil))) (let ((cua-delete-selection (not autopair-autowrap)) (blink-matching-paren (not autopair-action))) (call-interactively beyond-autopair)))
  autopair-fallback("
")
  (let ((pair (autopair-find-pair (char-before)))) (if (and pair (eq (char-syntax pair) 41) (eq (char-after) pair)) (progn (setq autopair-action (list (quote newline) pair (point))))) (autopair-fallback (kbd "RET")))
  autopair-newline()
  call-interactively(autopair-newline nil nil)
  command-execute(autopair-newline)

And after that the Enter key starts to work normally, but I do have to go through the toggle-debug-on-error every time I open Emacs.

I looked around but didn't find anything that could help me on that.

In my .emacs I've got the following reference to ansi-term:

(defvar my-term-shell "/bin/zsh")
(defadvice ansi-term (before force-bash)
  (interactive (list my-term-shell)))
(ad-activate 'ansi-term)

(defun my-term-use-utf8 ()
  (set-buffer-process-coding-system 'utf-8-unix 'utf-8-unix))
(add-hook 'term-exec-hook 'my-term-use-utf8)


texts: Evil mode leave insert state if save via I C-x C-s?

texts:
I use evil-mode (specifically in spacemacs) working in org-mode documents. Many times, after evaling code via C-c C-c or exporting via C-c C-e, I find myself saving via C-x C-s (old habits die hard). I then examine output and come back to the document only mangle it because I'm still insert mode.

Added complication: I'm on a chromebook, and I use emacs in a xiwi window, and I tried
(add-hook 'focus-out-hook (lambda () (interactive) (evil-normal-state t))), but clicking out of the xiwi window into a chromeos window doesn't register the focus-out. :-/

Is there a hook I can plug into so that if I save, I invoke emacs-normal-state?

Thanks!


texts:
Is there anyway that I can create citations with superscript numbers?1,2

1: https://guides.lib.uw.edu/c.php?g=99161&p=642357

2: https://example.com

And if outputting to a format with multiple pages (LaTeX) can the numbers reset each page?1

1: https://example.com

And as seen above, have a horizontal rule before the citations start?

The reasoning behind this is so that text formats that don't have links don't get cluttered up with links in-text, but formats that do have links can just jump straight to the link.


texts: How not to propagate dired-actual-switches as a directory variable to the sub directories

texts:
I want to set dired-actual-switches for the directory /path/to/data, but not for data's subdirectories. So I generated the following .dir-locals.el file in /path/to/data:

;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")

((dired-mode .
  ((dired-actual-switches . "-laht")
   (subdirs . nil))))

And as I hope for, when I call dired on the directory /path/to/data it is listed by date. However when I open a dired buffer for /path/to/data/sub the directory listing for sub is in date order as well - despite the subdirs . nil entry in .dir-locals.el.

How do I achieve that dired-actual-switches is only set for the directory the .dir-locals.el file sits in?


texts:
I can insert a date 2-days from now with:

C c . and then +2 or +2d among many other possibilities.

What is the equivalent for time? What can I use instead of +2d for inserting a date+time in two hours (or whatever other time from now). I tried +2h and +2:00, but no luck.


texts: Was org-iswitchb removed, and what is it's closest replacement?

texts:
Just getting started getting comfortable with Org. Part of my initial configuration was copied from the GNU manual:

 (global-set-key "\C-cb" 'org-iswitchb)

That didn't work ever; for posterity and Googlers, it was giving me this message:

  command-execute: Wrong type argument: commandp, org-iswitchb

M-x org-iswitchb did show "no match", too. So the function doesn't exist.

Today I discovered that iswitchb was removed from GNU Emacs in 24.4 according to emacswiki. So it seems org-iswitchb is gone for good, too, and it's not a configuration fault on my end.

What is the current equivalent? Is org-switchb it?

(I don't know how iswitchb behaved, so I cannot compare. Alternative suggestions are welcome, too; probably best fitting in the comments)


texts: Understanding uninterned symbols and macro expansion?

texts:
I want to demonstrate my lack of knowledge with an example.

Using the following two macro defintions,

(defmacro for (var from init to final do &rest body)
  "Execute a simple for loop: (for i from 1 to 10 do (print i))."
  (let ((tempvar 'max))
    `(let ((,var ,init)
           (,tempvar ,final))
       (while (<= ,var ,tempvar)
         ,@body
         (setq ,var (1+ ,var))))))

(defmacro for (var from init to final do &rest body)
  "Execute a simple for loop: (for i from 1 to 10 do (print i))."
  (let ((tempvar (make-symbol "max")))
    `(let ((,var ,init)
           (,tempvar ,final))
       (while (<= ,var ,tempvar)
         ,@body
         (setq ,var (1+ ,var))))))

the first macro shadows any variables named max which may
occur in the body and the second does not, which can be showed with
the following example:

(let ((max 0)) ;; this variable is shadowed if the first macro defintion is used
  (for i from 1 to 3 do
       (setq square (* i i))
       (if (> square max)
         (princ (format "\n%d %d" i square)))))

As far as I have learned the evaluation of a macro call works like this:

The macro gets evaluated twice. First the body gets evaluated and returns a form.
This form then gets evaluated again.

So far so good.

But if I assume that the macro really returns a chunk of
text which happens to be a lisp form, which then gets interpreted,
I get a conflict that makes me unable to understand the example above.

What chunk of text does the second macro which uses make-symbol return,
so that no shadowing occurs? In my understanding an extreme unlikely random choosen
symbol name would make sense.

If I use pp-macroexpand... both macros return the same expansion.

Is someone able to help me out of this confusion?


texts: How to pass flags to the LaTeX compiler with AUCTeX?

texts:
Consider the following two excerpts.

The imakeidx package's user manual states (version v1.3e, 2016/10/15, Section 1 Introduction, p. 2):

  depending on the distribution and the shell editor that is being used to work on a specific document, it is necessary to add -shell-escape (or
  --enable-write18 for MiKTEX) to the command with which the typesetting program is launched, possibly through the shell editor.

The tcolorbox package's user manual states (version 4.03, 2017/04/25, Chapter 22 Library external, p. 427):

  To use the externalization options, the compiler has to be called with the -shell-escape permission to authorize potentially dangerous system calls.

In both cases using a certain package, or activating some of its options, requires passing some flag(s) to the typesetting engine. For example, compiling the following LaTeX document:

\documentclass{article}
\usepackage[all]{tcolorbox}
\begin{document}
Hello, world!
\end{document}

results in the following error message:

  ERROR: Package minted Error: You must invoke LaTeX with the -shell-escape flag.

How can flags be passed to the typesetting engine using AUCTeX?


texts: How to point latex preview to another file?

texts:
I have two files.  A main file, say, main.tex which has all the boiler plate and structure, and section.tex, which has content.

Inside main.tex I have \include{section}.

I edit section.tex, because that's where the content is, and so when I use  latex-preview-pane-mode it gives an error, because it is trying to compile section.tex which has none of the necessary preamble.

Is there anyway I can point the preview pane towards main.tex, or some other way of achieving what I want: the ability to preview modular latex documents within Emacs?  Preferably it would be within a frame, rather than having to open an external application, and updates automatically in the way that latex-preview-pane-mode does.

Otherwise I will have to use a monolithic document once again and use C-c = with reftex, I suppose.


texts: How can I defer loading elpy using use-package?

texts:
I've been updating all my use-package calls now that :idle is no longer a decent way to defer stuff. At the moment one of the biggest hits on my load time is elpy which loads a whole bunch of additional modules. At the moment my invocation is rather basic:

(use-package elpy
  :commands elpy-enable
  :init (elpy-enable)
  :config
  (progn
    (setq elpy-rpc-backend "jedi"
          elpy-rpc-project-specific 't)
    (when (fboundp 'flycheck-mode)
      (setq elpy-modules (delete 'elpy-module-flymake elpy-modules)))))

However this is rather wasteful if I'm never editing any python modules. The trouble is elpy is a collection of modes so I can't just use the mode binding form as elpy-enable needs to get called. So what approach should I use. Is it just a case of triggering on the python-mode hook?


texts:
While the documentation states that archive mode supports rar files, I seem to have no luck with it. Trying to view/open a rar file in dired, lead to this message:

File mode specification error: (file-error Searching for program No such file or directory lsar)

My emacs version is 25.2.1. I suspect the source of the error is here, in using unar instead of unrar:

(defun archive-rar-extract (archive name)
  ;; unrar-free seems to have no way to extract to stdout or even to a file.
  (if (file-name-absolute-p name)
      ;; The code below assumes the name is relative and may do undesirable
      ;; things otherwise.
      (error "Can't extract files with non-relative names")
    (archive-extract-by-file archive name `("unar" "-no-directory" "-o") "Successfully extracted")))

I don't have experience modifying compiled emacs lisp libraries. Would love to know what is causing this error.


texts:
Just discovered scss-mode and it's concomitant compile-on-save (very cool). However, I keep getting errors because sass it is not reading ../config.rb.

I can find no variables in scss-mode nor params for sass (i.e.: scss-sass-options) which would feed in the config path.

How does one convince sass to read config.rb under compilation?


texts: No numpy, scipy, sympy and matplotlib minor-modes?

texts: Python scientific libs are immensily popular for the last decade or so. However googling and "melping" for its emacs minor-modes reveals nothing. Basically I need just syntax highlighting. Do you happen to know any efforts in this direction?


texts: How to use 'glossaries' package in aquamacs, or I mean how could I run makeglossaries in aquatics

texts:
I find the instruction from enter link description here as given below

\documentclass{article}

\usepackage[utf8]{inputenc}

\usepackage{glossaries}

\makeglossaries

\newglossaryentry{latex}
{
    name=latex,
    description={Is a mark up language specially suited
    for scientific documents}
}

\newglossaryentry{maths}
{
    name=mathematics,
    description={Mathematics is what mathematicians do}
}

\title{How to create a glossary}
\author{ }
\date{ }

\begin{document}
\maketitle

The \Gls{latex} typesetting markup language is specially suitable
for documents that include \gls{maths}.

\clearpage

\printglossaries

\end{document}

But I cannot get glossaries working. I know I need to run 'makeglossaries' or 'makeindex', but how could I do in aquamacs latex mode.

I tried C-c index

it shows

Running `Index' on `test2' with ``makeindex test2''
Couldn't find input index file test2 nor test2.idx.
Usage: makeindex [-ilqrcgLT] [-s sty] [-o ind] [-t log] [-p num] [idx0 idx1 ...]

So how could make this glossaries package working?

And the version of software I am using is Aquamacs 3.3  GNU Emacs 25.1.1

Thanks.


texts: how to make emacs think semicolon and brackets are words?

texts: i've came on emacs from Sublime Text, and there ;[]{}()., etc are counts as word, and when you move in your document with Ctrl+Arrow you never skip these characters. I want make emacs recognize all these characters as separate word. How do i? Is there easy way to do this?


texts: How to give all inputs of a multiple inputs command at one time

texts:
There are commands which take multiple inputs. My question is about the possibility of defining a new command which take all the inputs of another command at one time (separated by commas).

As an explicit example, after activating calendar (by M-x calendar), if one executes the command M-x calendar-goto-date, then it asks the year (put 2017), then the Month name (put July), then the day (put 7). It would be nice to give these inputs at one time like 2017,July,7. This is just an example, the question also arises in other situations.


texts: How to troubleshoot random hangs / pauses?

texts:
Short of building a debug version of emacs and adding break points.

Whats the best way to know whats happening during a 'pause' while emacs runs? (assuming the pause is long enough to manually run an operation)

Is there a way to press Ctrl-C in the terminal to get a stack trace or something similar?


texts: Search through the values of all variables in Emacs

texts:
I'd like to find which variables contain a certain value.

Is there a way to do a regex search through the values of every variable in Emacs?


texts: lsp-mode find symbol or refs *not* under point?

texts: Sometimes I know the name of the function I'm looking for but it isn't used anywhere in the current buffer. With the various tags utilities I was always able to just search for a definition by name, but lsp-find-definition seems to only operate on whatever symbol the cursor is currently on. Is there a way to get a prompt where I can type in a name to search for? Manually adding a use to the current buffer just so I can find the definition and then deleting it afterwards is very clunky. Would be especially nice to have something that would play well with read-completing-function so helm/ivy would work.


texts: How to prevent autocomplete from overriding my keybindings?

texts:
I've changed the keybinding C-s to save buffer, but when I'm writing code and autocomplete is visible, it rebinds this key to search for a pattern:

If I try to use C-h k to find out which function is bound to C-s, even with the autocomplete open, emacs tells me it's save buffer.

How can I find out what is overwriting the C-s keybinding, and how to avoid it?

I'm using GNU Emacs 24.5.1 on RHEL Linux, the active modes are Python Flymake AC.


texts:
I have a script containing this code:

(let
    ((JOURNALS
      '(

        ("abhandlungen aus dem mathematischen seminar der hamburgischen universitet" .
         "Abh. Math. Sem. Univ. Hamburg") ;; inSPIRE

        ("acm transactions on mathematical software" .
         "ACM Trans. Math. Software") ;; inSPIRE

        ("acs applied materials and interfaces" .
         "ACS Appl. Mater. Interfaces") ;; NLM Catalog

        )))

  ...

  )

and I need move the list of cons cells in a separate file. E.g.:

(let
    ((JOURNALS
      '( (read-file "list-of-cons-cells.el")

        )))

  ...

  )

Where the list-of-cons-cells.el file contents is:

("abhandlungen aus dem mathematischen seminar der hamburgischen universitet" .
 "Abh. Math. Sem. Univ. Hamburg") ;; inSPIRE

("acm transactions on mathematical software" .
 "ACM Trans. Math. Software") ;; inSPIRE

("acs applied materials and interfaces" .
 "ACS Appl. Mater. Interfaces") ;; NLM Catalog

What's the right way to load this file when I run my script?

Edit. This is a MWE of mi original idea (this is not the real function...):

(defun myfunction-orig ()
  (interactive)
  (let ((JOURNALS '(

                    ("abhandlungen aus dem mathematischen seminar der hamburgischen universitet" .
                     "Abh. Math. Sem. Univ. Hamburg") ;; inSPIRE

                    ("acm transactions on mathematical software" .
                     "ACM Trans. Math. Software") ;; inSPIRE

                    ("acs applied materials and interfaces" .
                     "ACS Appl. Mater. Interfaces") ;; NLM Catalog

                    )
                  ))

    ;; Debug:
    (princ JOURNALS)
    (sit-for 2)

    (while JOURNALS
      (read-string (car (car JOURNALS)))
      (setq JOURNALS (cdr JOURNALS)))))

I tried to modified it on phils' suggestion:

(defun myfunction ()
  (interactive)
  (with-temp-buffer
    (insert-file-contents "./list-of-cons-cells.el")
    (let (JOURNALS form)
      (while (setq form (ignore-errors (read (current-buffer))))
        (push form JOURNALS))
      (nreverse JOURNALS)

      ;; Debug:
      (princ JOURNALS)
      (sit-for 2)

      (while JOURNALS
        (read-string (car (car JOURNALS)))
        (setq JOURNALS (cdr JOURNALS)))

      )))

but it doesn't work.

Solution. This is the solution based on the edited phils' answer:

(defun myfunction ()
  (interactive)
  (let ((JOURNALS (with-temp-buffer
                    (insert-file-contents "./list-of-cons-cells.el")
                    (let (list form)
                      (while (setq form (ignore-errors
                                          (read (current-buffer))))
                        (push form list))
                      (nreverse list)))))
    ;; Debug
    (princ JOURNALS)
    (sit-for 5)

    (while JOURNALS
      (read-string (car (car JOURNALS)))
      (setq JOURNALS (cdr JOURNALS)))))


texts: How to open text links (hypertext) firefox with mu4e?

texts:
I have this function to open links in firefox with mu4e, which I found somewhere here.

;; open with firefox
    (defun my-browse-url-firefox-new-tab (url &optional new-window)
      "Open URL in a new tab in Firefox."
      (interactive (browse-url-interactive-arg "URL: "))
      (let ((cmd (shell-command-to-string
          (concat "~/src/firefox/mozilla-xremote-client -a any 'openURL("
              url ",new-tab)'"))))
    (unless (string= "" cmd)
      (message "Starting Firefox...")
      (start-process (concat "firefox " url) nil "/usr/bin/firefox" url)
      (message "Starting Firefox...done"))))

(define-key mu4e-view-mode-map (kbd "C-c C-o") #'my-browse-url-firefox-new-tab)

My problem is that it only works for "direct" links, not hypertext. If I have a link such as mylink, it displays URL: http://mylink, not URL http://www.example.com. Can anyone help?


texts: How to scroll through all available matching interactive (M-x) commands using Helm rather than just my history?

texts: I'm using Helm to perform completions for my interactive commands, but it only lets me cycle through those commands which I have used in the past (i.e. 4 Candidate(s)). I don't want this behavior, instead, when pressing C-n/C-p it should cycle across all pattern matched commands. How do I change this behavior?


texts: How can select text in a single window in a multi-window configuration?

texts:
When I have two buffers open side by side in as terminal (as shown in the screenshot), I cannot simply select text in a single buffer for copy and paste purpose. The selection will span across them, which is expected because it is how the terminal works.

My question is: is it possible to copy the text via Crtl-space and then put it in OSX's clip broad? (e.g. pipe the selected text to pbcopy?)


texts: Comment lines in org-mode with clean view

texts:
I want to insert a comment line between two top-level headings like this:

# first comment

* Top level headline
  * Second level
    * 3rd level
      some text
    * 3rd level
      more text

# second comment

* Another top level headline

Unfortunately the second comment shows up intended as part of the last 3rd level heading and it's impossible to unindent it:

# first comment

* Top level headline
  * Second level
    * 3rd level
      some text
    * 3rd level
      more text

      # second comment

* Another top level headline

Is it possible to override this behaviour?


texts: Auctex: Make it open a file chooser when inserting a href command

texts:
If I run C-c C-m href in auctex, it asks me which url to use. However if I want to link to a local file, it should let me choose the file but it doesn't.

How can I achieve this? Would be ok to bind this for example to C-u C-c C-m href or something like that.


texts: `ivy-read`: How to run action on every selection change?

texts:
I have been trying to implement a function with ivy that needs to run a particular function not only on selection but also on every selection change in the list.

To be specific, when the user scrolls the list of available options, the currently selected item from the list should be identifiable.

(ivy-read "Choose: "
          (list "one" "two" "three")
          :action (lambda (n)
                    (do-something n))
          :update-fn #'do-something-else)

The above code runs the lambda when a particular item (either one, two, or three) is selected and the return key is pressed. Also, with the update-fn in place, even typing one of the values does do-something-else and I can read the value typed as ivy-text. However, I need some action to be triggered when the user scrolls through the list of numbers without even typing.

Is that even possible?


texts:
I would like to auto-revert some remote image/pdf files.

I have activated the option
(setq auto-revert-remote-files t) and see that the file effectively auto-revert. Yet the image does not update. I need to go to the image buffer and toggle between editing or viewing the C-c C-c to see the changes.
Is there a way to avoid the last step?


texts: M-x man: Can't find the %s manpage caused by loading helm

texts:
I'm trying to figure out why Emacs won't display some man pages with my configuration using M-x man. It, however, does display them with emacs -Q. Not all man pages are affected. I can view the man page for ps but not the man page for ssh.
I worked through my init.el file and discovered my ability to generate the ssh man file ceases as soon as I load helm. What I did find whas that M-x helm-man-woman on ssh does work. So, I guess helm is screwing up other code inside emacs.
From peaking at the man.el source code I can't figure out how it could ever work. It is very complicated code and I am getting lost about what it's doing. It seems like Man-arguments gets assigned "" at some point, and then on line 1492 of lisp/man.el this leads to Emacs telling me it can't find the ssh manpage (or any other man page). I guess then somehow Man-page-list is not getting setup correctly. Why could this be? Presumably because (Man-build-page-list) is failing to do what it claims to do. How could any of this be related to helm?


texts:
windows 10, emacs 26.1
I have table in org file and I want to sort table by column Date

Here table:

|        Number |       Date |
|---------------+------------|
| 1535749200000 | 31.08.2018 |
| 1535835600000 | 01.09.2018 |
| 1590094800000 | 21.05.2020 |
| 1536019200000 | 04.09.2018 |
| 1536883200000 | 14.09.2018 |

Note: Date is in format "dd.MM.yyyy"

Here my steps:

M-x org-sort

Then press t

Here result.

As you can see it's not sort. And I get message:

You can run the command ‘org-sort’ with C-c ^


texts:
I want yasnippet to expand both "Cp" and "cp" into the same, say, "\citep{}".

How can this be done?  Is there a way to make yasnippet case insensitive?  As a quick-and-dirty solution, I tried creating yasnippet description files for both "cp" and "Cp", but only one of them is being recognized.  Any ideas?


texts: practical relevance of storing value and function into one symbol

texts:
With Emacs Lisp it is possible to store a value and a function within the same symbol.

(setq  foo 6)
(defun foo () (message "blah %d" foo)))

Then you can do:
(symbol-function 'foo) which returns the function (lambda nil (message "blah %d" foo)) and
(symbol-value 'foo) which returns the value 6.

Also you could evaluate (foo) which prints "blah 6".

This is cool, but is there any practical relevance?
(Is there a reasonable usage somewhere?)


texts: Why does (indent-region ...) insert a 't' into my buffer?

texts:
I'm using this yasnippet:

# -*- mode: snippet -*-
# name : case : {...}
# key: case
# --
`(indent-region (- (point) 20) (+ (point) 20) nil)`case ${2:constexpr}: ${3:\{}
    $0
    break;
${3:$(if (string-match "\{" yas-text) "\}" "")}

I think it's some default, but I'm not sure.  Until recently, this snippet worked fine, but now I get a t inserted into my buffer, and I think it comes from (indent-region):

        break;
t      case constexpr: {

          break;
        }
      case

How do I get rid of this t?


texts:
I am working on a project that includes some configuration in .dir-locals.el:

((c++-mode
  . ((compile-command . "cd ../../\; ./build.sh"))))

This gets picked up just fine for me and sets the compile command. A teammate's emacs doesn't seem to recognize the file. .dir-locals.el is present, but doesn't set the compile command (still defaults to make -k).

Evaluating (dir-locals-find-file "Foo.h") in *scratch* returns .../project/src on my system (which is the folder where .dir-locals.el is located), but returns nil for the teammate.

How do I troubleshoot this? Everything I can find in the documentation seems to assume that .dir-locals.el will get picked up if it's present.


texts: How do I search the whole word in swoop?

texts:
I wish to search a separate word with helm-swoop. There should be some trick for this I guess. For instance I know that to search 2 words will be like word1\|word2 and to search the end of the line like: endofline$

So does anybody know how to search a whole word only? Thanks.


texts:
I use TrueType fonts with Emacs under X.

There are specific Italic and Bold files for most fonts.

All of them are recognized by font config and therefore by emacs.

How does Emacs uses bold and italic? Does it use the specific font that is provided or does it modify the regular font to make it italic or bold?


texts: Predicate function to test if file is under version control?

texts: What is the predicate function to determine if a given file is under version control?  (I'm using git.)


texts:
When I execute a long running script within the org mode, emacs freezes. Is there a way to see the (running) output of the script? Alternatively, is there a way to run script asynchronously, and then get the output back into the org buffer?

I run my shell scripts the following way:

#+BEGIN_SRC shell
 ls
#+END_SRC

Thank you!

Edit: May be there is a way to run the command in a separate buffer, to observe output, and the put truncated output back to the main buffer?


texts:
During a magit-rebase I'm running into conflicts on single long lines, where I'd like to take some parts of the line from the A and some from the B buffer.

After hitting * -refine current region within magit-ediff-dwim I can view the wordwise diff between two buffers. However, the actual diff chunks to choose from are much bigger. Is it possible to update these chunks so I can resolve the conflicts word by word (similar to ediff-regions-wordwise)?


texts:
I have used keyboard macros for a long time, but moved between companies, systems, and various machines over my career.  I used to be able to record macros and insert-kbd-macro into my .emacs file and they look readable and concise:

(fset 'kc-del-blank-lines
      "M-x flush-lines return ^\s-*$ return")

On my latest, cygwin install (windows 10),  the same macro gets created like:

(fset 'kc-rmbl
   [?\M-x ?f ?l ?u ?s ?h tab return ?^ ?\\ ?s ?- ?* ?$ return])

Ok, the latter uses a vector ([...]) instead of a string ("...").  How can I get this install to produce the former results.


texts:
Ideally, I would like to be able to store the entire contents of my .emacs.d directory and have it "just work" on any Emacs I load it into, but still take advantage of any features of the specific environment, such as GUI windowing systems.

I'm not looking for an encyclopedia of
incompatible features. I'd just like to know how to check for features, OS, version, graphics, etc, and how to take advantage of these without breaking the code for other configurations.

What basic techniques can I use to write Elisp that works in multiple versions of Emacs common in the wild (e.g. 22.x+) and on multiple underlying platforms (e.g. OSX, Linux, Windows, and other *nix), while taking advantage of platform and version-specific features where applicable?


texts:
I'm trying to construct a regular expression that would match symbols, that
is, things like function names and the like, according to current major mode
settings (it's called syntax table if I remember correctly). After some
investigation, I have found these useful regexps:

\_< matches beginning of a symbol
\_> matches end of a symbol

Now I think I need to find out how to represent symbol-constituent
character. We have \w for word-constituent characters, but I cannot find
anything for symbols. Regexp to match symbols should be something like
(assuming that \s matches on symbol-constituent characters):

\_<\s+\_>

Am I missing something? How to match on symbols?

Note that matching on words does not work for me. Trivial example is
something like foo-bar that is a symbol in Emacs Lisp mode, but not a word
(because - is not a word-constituent character).


texts: How to build Emacs from sources on Termux

texts:
Background: Termux is a Linux terminal environment that runs under Android. It provides a terminal version of Emacs 25.3.

However, I would like to build Emacs directly from the master branch in the archive. However, I have stumbled on two problems:

1) The emacs build recipe for termux patches a number of files. I will need to apply those patches as well.

2) When running autoconf.sh (to generate the configure script), I get a number of errors. (I can't copy-paste from the android device, unfortunately). When running autoreconf -fi -I m4 the following is emitted:

/PATH/TO/bin/m4: m4_syscmd subprocess failed
configure.ac:5191: error: expected source file, required through AC_LIBSOURCES, not found
m4/gnulib-comp.m4:177:gl_INIT is expanded from...
configure.ac:5191: the top level
autom4te: /PATH/TO/bin/m4 failed with exit status 1
...

Does anybody has a step by step description on how to build Emacs from source on Termux? Alternatively, do you have any suggestion on how I should modify the build scripts myself so that they get the latest version rather than a specific one? (The build scripts downloads the sources as a tar.gz file, presumably with a pre-generated configure file, so a great help would be if someone would provide the latest sources the same way.)


texts: Dictation in Mac OS doesn’t leave spaces between words in Emacs

texts:
I have tried to use the dictation feature of Mac OS in Emacs and it works quite well, except that it doesn’t seem to recognise spaces between words if I pause shortly and also omits spaces between sentences. Example:

  This is a testAnd dictation in Emacs. It seems like spaces are omittedIf you use the dictation Feature.Is this possible to solve?

Reading this answer on apple.stackexchange it seems like it has to do with the interaction between the feature in the OS and the application, in this case Emacs.


texts: How can I check the implementation of a builtin function?

texts: Is there a way to check the implementation of a builtin function (e.g. load-file) without cloning the Emacs repository?


texts: How to sort by KIND in helm-find-files (Emacs)

texts:
I know there is such a variable as helm-ff-initial-sort-method.
However, it does not include KIND as a sorting method.
Anybody know how to sort files in helm-find-file by KIND?
Thank you!


texts: How to distinguish input from the return value of body in while-no-input?

texts:
(while-no-input &rest BODY)
Execute BODY only as long as there's no pending input.
If input arrives, that ends the execution of BODY, and while-no-input
returns t.  Quitting makes it return nil. If BODY finishes,
while-no-input returns whatever value BODY produced.

If the BODY returns t then there is no way to distinguish it from the input interruption. One way could be to check if the return value is t in the BODY itself and then return certain value like 293851932832985. Is there a cleaner way?


texts:
Is there a way to do syntax highlighting in org-mode code blocks without using: (setq org-src-fontify-natively t)?

Since v. 8, I have been unable to fontify the background for org-block with this option enabled.
Would love to fontify my code blocks though!


texts: "replace-match" leaves first letter capitalized

texts:
I'm writing a little cleanup function that will search for the word 'let' in a case insensitive manner then replace it with the lowercase 'let'.  It works in all my test cases, except for when the first letter is capitalized:

leT x=1
Let y=2
let z=3
lEt a=3

In the output, the second line is wrong:

let x=1
Let y=2
let z=3
let a=3

Here's the elisp:

(defun let-cmd()
  (goto-char (point-min))
  (while (search-forward-regexp "Let" nil t)
    (replace-match "let" (match-string 1)) t nil))

(defun cleanup()
  (interactive)
  (let-cmd))

How do I fix this one example?


texts: Is there a way in Flycheck flake8 mode to ignore a specific warning?

texts:
As we all know sometimes it's OK to break the rules. Flycheck Mode however, isn't as forgiving and happily displays it's warning.

Is there a way to disable this on a per line basis when using flake8? For example: Adding a comment # fc:ignore on the same line as a warning you want to ignore.


texts: live refresh of inline images with org-display-inline-images

texts:
Recently I've noticed the function I had been using to do refresh had stopped working and I had to change to a simpler call.

I used to have:

(defun k/org-babel-refresh-inline-images ()
  (org-display-inline-images nil t))

(add-hook 'org-babel-after-execute-hook 'k/org-babel-refresh-inline-images)

which had been recommended on the mailing list.

However, that stopped working and I've found:

 (add-hook 'org-babel-after-execute-hook 'org-display-inline-images)

to work, but I'm not sure why the original stopped working. Presumably, the original version might be more efficient if it worked. Why doesn't it, and why was the original preferred?


texts: evil mode: how to move cursor in insert state?

texts:
I am trying out evil mode, and I want to rebind something to four arrows so I can move conveniently up-down-left-right when I am in insert state. In other words, which functions in emacs/evil that I can call to make the cursor move like pressing the arrows?

If you do not use the arrows to move in insert state, how do you move?


texts: Writing a `Company` backend: how to give control to the next backend?

texts:
I wrote a backend for COMPANY.

;;----------------COMPANY BACKEND-----------------------------

(defvar oef-mode-completions '()
  "The content of this variable is generated automatically for COMPANY completion."
  )

(setq oef-mode-completions
      (append  oef-answers-options
           oef-definitions-commands
           oef-commands
           oef-definitions-special-commands
           oef-doc-commands
           oef-storage-types
           oef-menu-exo-init-types
           oef-menu-doc-init-types
           oef-defined-variables
           oef-comparison-operators
           oef-language-reserved-words
           oef-definitions-wims-functions
           oef-wims-functions
           oef-definitions-slib-scripts
           oef-slib-scripts
           oef-pari-functions
           oef-maths-functions
           oef-random-functions
           oef-canvasdraw-commands))

(defun company-oef-mode-backend (command &optional arg &rest ignored)
  (interactive (list 'interactive))

  (case command
        (interactive (company-begin-backend 'company-oef-mode-backend))
        (prefix
         (and (eq major-mode 'oef-mode)
              (company-grab-word))
         )
        (candidates
         (remove-if-not
          (lambda (c) (string-prefix-p arg c))
          oef-mode-completions))
;;      (meta (format "This value is named %s" arg))
        )
  )

(add-to-list 'company-backends 'company-oef-mode-backend)

It's working but it doesn't give the control to the next backend.
If I look at the documentation C-h v company-backends I read :

  ‘prefix’: The backend should return the text to be completed.  It must be
  text immediately before point.  Returning nil from this command passes
  control to the next backend.

Until now my code return the word or an empty string that's why the next backend is ignored.


texts: Function: "Symbol's function definition is void" until I C-h C-f its definition, then works fine

texts:
I've defined a function that uses popup-tip. On startup, if I call the function, I get the error, Symbol's function definition is void: popup-tip. If I call Ch Cf for popup-tip, I can find the definition. Then, thereafter, the function works as expected.
I don't know what this could possibly mean.
Here's the function, if relevant. I've stolen it from here:
https://gist.github.com/jasonm23/eea3b4662e2a3028a07e
(defun describe-in-popup (fn)
  (let* ((thing (symbol-at-point))
         (description (save-window-excursion
                        (funcall fn thing) ;; This is the yield point
                        (switch-to-buffer "*Help*")
                        (buffer-string))))
    (popup-tip description
               :point (point)
               :around t
               :height 30
               :scroll-bar t
               :margin t)))
(defun describe-thing-in-popup ()
  (interactive)
  (let* ((thing (symbol-at-point)))
    (cond
     ((fboundp thing) (describe-in-popup 'describe-function))
     ((boundp thing) (describe-in-popup 'describe-variable)))))

(global-set-key (kbd "C-h C-h") 'describe-thing-in-popup)


texts: Copying the contents of source blocks to clipboard

texts:
Suppose our buffer reads:

* Test
#+BEGIN_SRC mathematica
Manipulate[Plot[{x^{a-1}, E^{-x}}, {x, 0, 10}], {a, 0, 10}]
#+END_SRC

#+BEGIN_SRC mathematica
2+2
#+END_SRC

#+BEGIN_SRC mathematica
E^{-2}
#+END_SRC

Is there a way to copy all of the source blocks so that something like the following gets copied to your clipboard?

Manipulate[Plot[{x^{a-1}, E^{-x}}, {x, 0, 10}], {a, 0, 10}]
2+2
E^{-2}


texts: Why doesn't generate-new-buffer work in M-x?

texts:
According to the documentation generate-new-buffer "buffername" creates a new empty buffer with the given name, yet when I try it in M-x the prompt refuses the name and replaces it with "No match". Does it mean it works with only preconfigured names?

At http://ergoemacs.org/emacs/emacs_new_empty_buffer.html there is an example where it is used as (generate-new-buffer "untitled"), so why doesn't work with M-x?


texts: How can I open my extern file browser (Nautilus) with C-c C-a f in emacs Org Mode using attachments?

texts:
I work with attachments (C-c C-a) in Emacs Org Mode.

I configured the variable org-file-apps to open pdf with the default PDF Viewer of my OS (in my case evince in Ubuntu 18.04), when I use the key binding C-c C-a o (instead of C-c C-a **O** to force emacs to open it in emacs).

I want the same for directories, but I don't know how to configure the variable org-file-apps to start nautilus with the desired directory.


texts:
How can I tweak Emacs auto-fill to fill when a period is inserted?

For example, with a (setq fill-column 10) the following will auto-fill when I press the space after "fill".

;; good fill

;; good
;; fill on

This example doesn't fill when I press the period.  I have to invoke
fill-paragraph manually

;; bad fillllllllllllllllll.

;; bad
;; fillllllllllllllllll.


texts: Disable prompting to auto-recover when auto-save data is the same as file

texts:
When I kill emacs (with killall emacs from a shell prompt, for example), and I was editing a file, Emacs restarts with a message

  filename has auto save data; consider M-x recover-this-file

If I had recently saved the file, then modified it and then undone the changes, so that it looks just like the saved version, this message is displayed, even though the auto-save file has no changes at all (seen via file size or M-x diff)

How can this be disabled?

I could not find something in either the official documentation, or emacswiki.


texts: How do I control how the contents of an element/object are combined when defining an org-mode export backend?

texts: I'm working on implementing a custom Org mode backend and trying to understand how the exported contents of an element/object are combined together by the export system. It seems like everything is done in a bottom-up manner, with the transcoder function corresponding to an element's type being called with the element, its already-encoded contents, and the plist containing the export environment. It's this second argument I'm interested in: it seems like each element/object in the parent's contents is encoded separately, then all the resulting strings are joined together somehow to make a single string that's then passed to the parent's transcoder function.  Is there any way to control how this joining process happens? The backend is for exporting to JSON so it's crucial that everything is joined correctly with commas, and I'd like to be able to control the whitespace too.


texts: What is a statistics cookie in Org mode and what is their use?

texts:
I am learning to use Org-mode. The manual mentions that command org-ctrl-ctrl-c works depending on the context. One of the examples is that if the cursor is on a statistics cookie, it updates it.

What is a statistics cookie? Are there other kinds of cookies? Is the concept of cookies general to Emacs or specific to Org-mode?

I am still learning so I apologize for this naive question but I asked only when searching on DuckDuckGo and Google did not produce a satisfactory result. One result did offer some clarification but I wanted more. That link is http://iso.mor.phis.me/projects/mlorg/docs/SYNTAX.html#Statistics_cookies .


texts: ghc-mod template generation (M-t) not working

texts:
I've been following this Emacs+Haskell tutorial and I'm going through the Insertion Commands section.

With Emacs 24.4.1, GHC 7.10.1 and ghc-mod master build, I've managed to get C-u M-t to work, so it generates implementations for both instance Eq ExampleType where and maybeMap :: Maybe a -> (a -> b) -> Maybe b

However, I'm now trying to get maybeMap x f = _maybeMap_body to expand, so I position myself on top of x, then execute M-t but nothing happens. The status bar indicates Nothing to be done.

Any idea what it's wrong here or how to debug it further? Could it be a bug?

NOTE The reason I'm using ghc-mod master is because with updated Cabal 1.22 and GHC 7.8 I was having this issue. Once I updated to GHC 7.10, I was having this other issue, so ended up having to build/install master ghc-mod to get it to work...


texts: How to indent the selected line one "tab" forward or backward

texts:
In a lot of text editors there is a keystroke used to move the selected lines one "tab" to the right, usually 4 whitespace or one "tab" to the left.
How can I do this in emacs? I have only found automatic indentation like C-M-|


texts: I have some code that runs in a hook that I want to change to only execute only if the left mouse button is not currently held down. I don't see any obvious functions or variables that let me directly query the mouse button state. What's the easiest way to do this?


texts:
I often find myself copying a region of code that is deep inside the indented structure. Since I don't want it to end up in a codeblock with superfluous indentation (given that the context is missing), I find myself remembering that and having to go back to select the region, then press < a couple times (I use evil) to shift the region left until leading indentation is removed, before I go ahead and copy again, then I have to undo the indentation by pressing u an equivalent number of times.

I was therefore thinking of automating this by creating a command for it and a bind to go with it. I tried searching to see if something like this already existed (I figured it surely would) but I guess I'm not having any luck with the way I'm formulating my queries.

What I'm curious about is if there's already a command or package for this.

Short of that, if there's a reliable, consistent way to remove the "leading" indentation, which I guess means removing the minimum indentation (of all lines, potentially 0 if already not indented) from each line in a region.

For example, this:

  (defun my-dots-search ()
    (interactive)
    (let ((helm-ag--extra-options
           "--hidden --ignore-dir .git --ignore .gitignore --ignore .projectile"))
      (helm-do-ag my-dots-path)))

That has 2 spaces of leading indentation, determined by mapping each line to its leading indentation and taking the minimum of that. So removing that leading indentation would involve removing 2 spaces from each line, to arrive at this:

(defun my-dots-search ()
  (interactive)
  (let ((helm-ag--extra-options
         "--hidden --ignore-dir .git --ignore .gitignore --ignore .projectile"))
    (helm-do-ag my-dots-path)))

If there isn't a function for this, I guess I could write it myself, so I would appreciate some pointers on things to look out for that I may be overlooking.

I imagine I would call such a function within a save-excursion to easily "undo" things once I'm done copying the region.

EDIT: This is my rough, first pass. I'm wondering if I'm making it unnecessarily complicated, doing something wrong, or if there's something I'm overlooking.

(defun my--copy-without-leading-indentation (region &optional indent-to)
  (let* ((lines (s-lines region))
         (indent-lengths (--map (or (cdar (s-matched-positions-all "^[[:space:]]+" it))
                                    0)
                                lines))
         (indent-lengths-and-lines (-zip indent-lengths lines))
         (non-empty-line-indents (--map (car it) (--filter (s-present? (cdr it)) indent-lengths-and-lines)))
         (min-indent (if non-empty-line-indents (-min non-empty-line-indents) 0))
         (unindented-lines (--map (if (or (= min-indent 0) (= (car it) 0))
                                      (cdr it)
                                    (substring (cdr it) min-indent))
                                  indent-lengths-and-lines))
         (indented-lines (when (and indent-to (> indent-to 0))
                           (--map (if (s-matches? "^[[:space:]]*$" it)
                                      it
                                    (concat (s-repeat indent-to " ") it))
                                  unindented-lines)))
         (resulting-lines (or indented-lines unindented-lines))
         (joined (s-join "\n" resulting-lines)))
    (kill-new joined)))

(defun my-copy-without-leading-indentation (arg start end)
  "Copy the region without any leading indentation.

With argument, after removing leading indentation, indent to 4 spaces.
This is useful for Markdown codeblocks, for example."
  (interactive "P\nr")

  (let ((region (filter-buffer-substring start end)))
    (my--copy-without-leading-indentation region (when arg 4))))

When given the prefix argument it indents by 4 spaces, useful for unfenced markdown codeblocks. I'm gonna try to polish and clean it up, and maybe optimize it some more.


texts: How to remove empty lines of a selected region of code in Emacs?

texts:
Is there a way to remove blank lines from a region of code I select?

I am asking because I copy/pasted code and it seems to have several blank lines I want to get rid off.


texts: Emacs crashes on resize every time starting under X11/GTK3

texts:
I just built emacs with X11 support on Debian, but every time I start it, the window pops up and works just fine until I resize the window, at which point it crashes.

user@host:~/emacs-26.1$ ./src/emacs
X protocol error: BadRequest (invalid request code or no such operation) on protocol request 130
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.
Fatal error 6: Aborted
Backtrace:
./src/emacs[0x506845]
./src/emacs[0x4ecc04]
./src/emacs[0x5068d3]
./src/emacs[0x4bb663]
./src/emacs[0x4bf0a7]
./src/emacs[0x4bf12b]
/usr/lib/x86_64-linux-gnu/libX11.so.6(_XError+0x11d)[0x7f5b89a4522d]
/usr/lib/x86_64-linux-gnu/libX11.so.6(+0x42157)[0x7f5b89a42157]
/usr/lib/x86_64-linux-gnu/libX11.so.6(+0x42215)[0x7f5b89a42215]
/usr/lib/x86_64-linux-gnu/libX11.so.6(_XReply+0x238)[0x7f5b89a43128]
/usr/lib/x86_64-linux-gnu/libX11.so.6(XQueryPointer+0x8e)[0x7f5b89a392be]
/usr/lib/x86_64-linux-gnu/libgdk-3.so.0(+0x584ea)[0x7f5b8b8d84ea]
/usr/lib/x86_64-linux-gnu/libgdk-3.so.0(+0x77045)[0x7f5b8b8f7045]
/usr/lib/x86_64-linux-gnu/libgdk-3.so.0(gdk_window_get_device_position_double+0x10b)[0x7f5b8b8ca6eb]
/usr/lib/x86_64-linux-gnu/libgdk-3.so.0(gdk_window_get_device_position+0x2d)[0x7f5b8b8ca7ed]
/usr/lib/x86_64-linux-gnu/libgtk-3.so.0(+0x33c299)[0x7f5b8bebc299]
/usr/lib/x86_64-linux-gnu/libgtk-3.so.0(+0x33c7ff)[0x7f5b8bebc7ff]
/usr/lib/x86_64-linux-gnu/libgdk-3.so.0(+0x2b6e8)[0x7f5b8b8ab6e8]
/lib/x86_64-linux-gnu/libglib-2.0.so.0(+0x4b123)[0x7f5b8a1bb123]
/lib/x86_64-linux-gnu/libglib-2.0.so.0(g_main_context_dispatch+0x15a)[0x7f5b8a1ba6aa]
./src/emacs[0x5d7d18]
./src/emacs[0x5a64bd]
./src/emacs[0x41e703]
./src/emacs[0x4f8e3b]
./src/emacs[0x4f9cb4]
./src/emacs[0x4fb784]
./src/emacs[0x56006e]
./src/emacs[0x4ecff4]
./src/emacs[0x56000c]
./src/emacs[0x4ecfb0]
./src/emacs[0x4f1f53]
./src/emacs[0x4f22ab]
./src/emacs[0x414cf3]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf1)[0x7f5b86ed02e1]
./src/emacs[0x415a7a]
Aborted (core dumped)

The GTK bug mentioned in the dump is a very old bug (opened in 2002) that was resolved as obsolete within the past few months.

Is this possibly an issue with my configuration or is this a bug I should report to emacs-devel/GTK?


texts: How can I do a git diff on the current file with magit?

texts:
I'd like to do a diff on the current file / buffer compared to the git repository.

Ideally a single function that could be called, or binded to a keyboard shortcut.


texts: Jump to a `cl-defstruct` defined function like `find-function`

texts: A cl-defstruct may create several functions.  I would like to jump to the initial definition where everything is defined, similar to find-function.  How can I do that?


texts: How to step into a c++ std library function in gdb/gud

texts:
This is most likely an issue with g++/gdb/other, but an indirect issue within Emacs nonetheless.

Whilst debugging, I would like for Emacs to step into the standard library implementation of the overloaded << operator function called from object std::cout.
As is shown in the series of screenshots when the current source file (in the source file window) switches from main.cpp to funct.cpp when function funct() is called:

Screenshot 1
Just starting the debugging session.

Screenshot 2
One step taken; thus changing the source file I'm looking at.

Screenshot 3
One step taken; std::cout << "ok\n"; is completely stepped over; when I would like to be directed to another source file.

The command I used to compile the files:
g++ -g -std=c++11 main.cpp funct.cpp

If someone could guide me through step-by-step of how they got this to work, that would be a great example to learn from; or if any more information is needed (whether it be the system I'm using, file-paths, etc.), please ask away.


texts:
I'm having a very basic problem with getting my emacs to talk to the GNU package repository.
The contents of my .emacs are
(require 'package)
(package-initialize)
(package-refresh-contents)

When I start up emacs, I see
Contacting host: elpa.gnu.org:443
Package refresh done
Failed to download ‘gnu’ archive.

When I do M-x toggle-debug-on-error and then M-x package-refresh-contents, I get the following stacktrace:
Debugger entered--Lisp error: (file-error "https://elpa.gnu.org/packages/archive-contents" "Bad Request")
  signal(file-error ("https://elpa.gnu.org/packages/archive-contents" "Bad Request"))
  package--download-one-archive(("gnu" . "https://elpa.gnu.org/packages/") "archive-contents" nil)
  package--download-and-read-archives(nil)
  package-refresh-contents()
  funcall-interactively(package-refresh-contents)
  call-interactively(package-refresh-contents record nil)
  command-execute(package-refresh-contents record)
  execute-extended-command(nil "package-refresh-contents" "package-refre")
  funcall-interactively(execute-extended-command nil "package-refresh-contents" "package-refre")
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)

I originally was trying to connect to Melpa, but I saw I have this issue even working with just the GNU archive. I'm on Emacs 26.2, macOS 10.14.6.
Any ideas?


texts: Make Emacs diff files before asking to save

texts: When I run save-buffers-kill-emacs or projectile-kill-buffers I get asked to save changed buffers. But for me a lot of these buffers do not differ from the file on disk. Can I make Emacs diff the buffer and file and only ask if there are differences? It can assume "no" or "yes" if there are no differences ("no" is preferred but I'm not picky).


texts: How do I define a function in my init.el and make it available with M-x?

texts:
I have the following function, which does what it says on the tin -- swaps the values of the ns-alternate-modifier and ns-right-alternate-modifier variables.

(defun swap-left-and-right-alt ()
  "Swap left and right alt keys"
  (setq ns-alternate-modifier
        (prog1 ns-right-alternate-modifier
          (setq ns-right-alternate-modifier
                ns-alternate-modifier))))

When I put this in my init.el, I don't get any errors, but I also don't get a M-x autocomplete for swap-left-and-right-alt, and if I type it out I get [No match].

I've read the manual section on defun and the section following it on installing function definitions, and it seems reasonable to think my problem is that the function isn't installed. However, when I try to install it by hand (following the manual) by opening the init.el, placing the cursor at the end of the function definition, and hitting C-x C-e, though this does do something (I see swap-left-and-right-alt in the minibuffer), it still doesn't do what I want, i.e. M-x swap-left-and-right-alt still gets me [No match].

(There is one difference: after the C-x C-e experiment, if I try to evaluate swap-left-and-right-alt, I get Symbol's value as variable is void, whereas just having it in the init file I get the debugger, with Lisp error: (void-variable swap-left-and-right-alt). Also, evaluating (swap-left-and-right-alt), with parentheses, does appear to run the function, i.e., the keys get swapped.)

Clearly there's a conceptual piece that I'm missing, but I haven't been able to hit on the right combination of Emacs-speak search terms to find the answer.

What do I need to put in my init file to

install the function, and
be able to autocomplete and run the function as a command?


texts:
Is it possible to make emacs as an input middle man for any text field in the system? It should work like this:

1 user focus the text input field of any gui program

2 a system hotkey brings up a dedicated emacs buffer

3 user do the editing in that emacs buffer

4 when finished editing, a short cut key send text to the original text input field

Possible problem is between step 3 and 4, the user may change windows.

Possible reference is the input method program fcitx, which has a pre-edit window, the editing is done in a separated popup window, a key need to be pressed to commit the content. What we need is to change the pre-edit window to an emacs buffer.

issue on fcitx tracker (https://github.com/fcitx/fcitx/issues/232)


texts:
I am new to org-mode and I am learning to use it to replace markdown for academic writing.

M-x org-ref gave me this error: org-ref  "Unbalanced parentheses", 20306, 18248 error
What should I do about it?

The error seems to have something to do with my .bib file.

It works with one .bib file, after validation, though not completely. But fails in another.

The same error occurs when trying to validate that .bib file with M-x bibtex-validate under bibtex-mode.

Both files have been generated by better-bibtex in Zotero.

Debugger:

When validating thesis.bib

Debugger entered--Lisp error: (scan-error "Unbalanced parentheses" 20306 182486)
  scan-sexps(20306 1)
  forward-sexp(1)
  bibtex-parse-field-string()
  bibtex-parse-field-text()
  bibtex-parse-association(bibtex-parse-field-name bibtex-parse-field-text)
  bibtex-parse-field()
  bibtex-valid-entry()
  bibtex-validate(nil)
  funcall-interactively(bibtex-validate nil)
  call-interactively(bibtex-validate record nil)
  command-execute(bibtex-validate record)
  execute-extended-command(nil "bibtex-validate" "bibtex-vali")
  funcall-interactively(execute-extended-command nil "bibtex-validate" "bibtex-vali")
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)

toggle-debug made no difference in org-mode.


texts:
I'm trying to get the formatting right for an org-mode file being exported to pdf.  I set 'org-startup-truncated' to nil and that has resolved my word wrapping issues for non code blocks.  But I cannot figure out how to set word wrapping or preventing lines from getting truncated within code blocks.  Is there a way to accomplish this?

Here is a screenshot of the relevant pdf section.  Notice the variable 'buffer' running off of the page.

Here is the text from my org file:

#+BEGIN_SRC python
#!/usr/bin/python
import socket

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

#buffer = 'Aa0Aa1Aa2Aa3Aa4Aa5Aa6Aa7Aa8Aa9Ab0Ab1Ab2Ab3Ab4Ab5Ab6Ab7Ab8Ab9Ac0Ac1Ac2Ac3Ac4Ac5Ac6Ac7Ac8Ac9Ad0Ad1Ad2Ad3Ad4Ad5Ad6Ad7Ad8Ad9Ae0Ae1Ae2Ae3Ae4Ae5Ae6Ae7$'
#+END_SRC


texts: Fuzzy completion when inserting Unicode characters

texts:
I just discovered C-x 8 RET as a way to insert Unicode characters by Unicode name or hex code.  I have not (yet?) memorised all Unicode character names, so I don't always find the right character.

There is, for example, the character "SNOW CAPPED MOUNTAIN".  If I type just "MOUNTAIN" this character will not appear the completion list.  I need to remember to search for "SNOW" to see this particular character in the list of completions.

As someone who has become dependent on IDO for anything involving completion, this lack of flexibility is rather unnerving.  I use ido-ubiquitous-mode.

How can I use IDO-like matching for Unicode input?  How can I use flexible completion for ALL THE THINGS?

(I would be okay with abandoning IDO mode if there was something better.)


texts: Tramp connection fails with "timeout reached"

texts:
I've been using tramp to edit remote files for a few years now, but suddenly it stopped working yesterday. I haven't changed anything relevant that I can think of. For testing, I tried opening a file on localhost with \C-x C-f /ssh:localhost:/home/terdon/test. That bring up the Waiting for prompts from remote shell... message and times out after about a minute with:

Timeout reached, see buffer '*tramp/ssh localhost*' for details

The *tramp/ssh localhost* is shown in the buffers menu but disappears as soon as I try to switch to it.

Details

I am running GNU emacs 25.3.1 on Arch Linux.
I have updated my system and the elpa packages I have installed.
To rule out problems with the remote prompt, I have replaced my ~/.bashrc and ~/.profile with:

$ cat ~/.bashrc
PS1='$ '
$ cat ~/.profile
PS1='$ '

Yes, my default shell is bash and no, I don't have a ~/.bash_profile.
I have set up passwordless ssh to all the servers that I've tried and which used to work. Including localhost (ssh localhost works fine with no password).
My .emacs file has (the full file can be found here: https://pastebin.com/QGgPE3SS):

(setq tramp-default-method "sshx")
(setq tramp-verbose 10)

The contents of the *debug tramp/ssh localhost* buffer are here: https://pastebin.com/F6r6d5cN.
I read Tramp: Waiting for prompts from remote shell... Sending command `exec ssh -e none bin' and added these lines to my ~/.ssh/config file:

Host *
  ControlPath ~/.ssh/master-%r@%h:%p
  ControlMaster auto
  ControlPersist = no

However, despite that, as you can see in the output in the previous bullet point, I still get command-line line 0: Missing ControlPersist argument line. Is that an issue?
Running the ssh command from tramp's log maually works fine:

$ ssh -o ControlMaster=auto -o ControlPath='tramp.%C' -o ControlPersist=no -e none localhost
Last login: Tue Apr 24 13:58:15 2018 from ::1
$

Trying the same thing after loading emacs with emacs -Q gives the same problem, so it isn't something to do with my ~/.emacs.
I created a new user with default settings and tried as that user and it worked! So while emacs -Q doesn't solve the issue, running as a new user does! What could cause that?

What else can I check? How can I get my tramp back again?


texts: Separately sum positive/negative numbers?


texts: pdf-tools-install takes a long time on startup

texts:
I've installed pdf-tools through MELPA, and it works like a charm. Funnily, and as is documented in the readme, the command pdf-tools-install needs to be run each time if you want pdf-tools to be enabled; (require 'pdf-tools) is not enough (the use of the word "install" in the command name is a little bit misleading). The only thing is, it takes 12 seconds or so to run pdf-tools-install from my init.el file (clocked using esup).

So what I've done is the following:

(with-eval-after-load 'tex
  (pdf-tools-install)
  (setq TeX-view-program-selection '((output-pdf "pdf-tools")))
  (setq TeX-view-program-list '(("pdf-tools" "TeX-pdf-tools-sync-view"))))

which allows it to only load when I'm in tex mode, which is nice. But it still means it takes an extra 12 seconds to load any tex file I want to work on, if I haven't loaded it in my current emacs session.

Call me impatient, but I literally moved to emacs from a more bloated editor in order to reduce startup times!! Is there any reason anyone can think of why it's taking so long to load pdf-tools-install, and a solution? Thanks in advance!

EDIT: Because of discussions following this issue, I replaced pdf-tools-install with (require 'pdf-tools) in my init.el just to make sure that pdf-tools-install is indeed required, and it seems that it is. Using (require 'pdf-tools) does not properly initiate pdf-tools, and pdfs are displayed using the normal DocView mode, rather than pdf-tools' PDFView mode.


texts: saving cloned buffers in workspaces/desktops/perspectives etc

texts:
i would like to be able to save a window (in emacs terms) layout with cloned buffers. i don't need it to save a series of buffers, i just need to be able to load a complex window layout when i work on a particular file. i want to show narrowed headings in different windows.

i know i can save layouts to a register and this works, but only as long as the emacs daemon is going. i wd prefer a solution that didn't rely on the emacs daemon. the file is a long term project.

i know i can save my register by saving the desktop, but this doesn't work: the register is saved but it doesn't open my cloned buffers correctly, it gives ```Error (frameset): font 'tty' is not defined and doesn't open them. (i tried both frame and window registers)

i tried persp-mode. it saves the windows correctly, and the buffers in them even have the names of clones, but they're completely empty when i load. (& can't unnarrow to anything.) this model (saving to a user defined file), seems like the right approach tho.

i tried persistence-mode. it restored no windows, and no cloned buffers, only frames.

workspaces2 is basically unmaintained.

perhaps someone has experience with fulfilling this kind of need.


texts: latex inside table using table.el in org mode

texts:
I am trying to achieve multicolumn cells in org-mode tables like in Multicolumn cells in org-mode tables, but with Latex inside the cells.

  * Minimal Example
  +------------+-----------+--------------+
  |            |           \pi            |
  |            +-------------+------------+
  |            |$\pi$        |            |
  +------------+----+--------+------+-----+

I found https://orgmode.org/manual/Tables-in-LaTeX-export.html and tried

  #+ATTR_LATEX: :mode math

and

  #+ATTR_LATEX: :mode math-inline

but no success.

The exported tex in the tex file is

    $\backslash$pi
    \$$\backslash$pi\$.

Can I protect the string in the cell?
Is it possible?


texts: How to use an external command to modify selected words and lines?

texts:
Something I've found useful in other editors is the ability to:

take the selected text
run an external command and pass the selection to its stdin
take the external commands stdout and replace the current selection with it.

This way you can write useful text tools which operate on the selection using any language that can do basic io.

How can this be done with emacs using the selection?
... a single character, word, paragraph... etc.

(Directly in the command line, or via a key binding?)

Note

The reason I'm asking this question is because I would like to operate on the selection. (i.e., the text that would be removed if x was pressed).
In evil-mode !sort for example only works on a line-level.


texts: Enabling auto-fill-mode only when document already filled

texts:
I have turn-on-auto-fill as part of my text-mode-hook. This works great for new documents, but when I open a buffer that is not filled with hard breaks I rarely want to start doing so to a single paragraph just because I make one edit to the buffer.

Is there a way to scan the whole buffer after opening to see whether it already is auto-filled? And turn on auto-fill-mode in that case but leave it off otherwise?

I've searched EmacsWiki and MELPA Stable and didn't see anything relevant.


texts:
I've read several answers on here and on Google and have tried several solutions but nothing is fixing this for me.

Right now, if I try to write C code Emacs indents it like so:

#include <stdio.h>

    int main()
    {
    printf("Hello");
    }

I would think main() should really be on the same indentation level as #include.  Also, I would think the printf() line should be indented further in than the curly braces.

The suggestions I've found here and elsewhere say to put this in my .emacs file, which I did:

;;C configuration
(require 'cc-mode)
(setq-default c-basic-offset 4)
(setq c-default-style (cons '(c-mode . "java") c-default-style))
(setq-default tab-width 4 indent-tabs-mode t)
(define-key c-mode-base-map (kbd "RET") 'newline-and-indent)
(add-hook 'c-mode-hook
       (lambda ()
         (setq-local electric-indent-chars
                     (remq ?\n electric-indent-chars))))

Sorry for being such a newb.  Can you help point me in the right direction as to why this is going wrong?


texts: About `fill-paragraph` in `markdown-mode`

texts:
I have a buffer on markdown-mode with the following contents.

        10         20        30        40        50        60        70

- a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a
  a a a a a a a a a a a a a a a a a a a a a a a a

- A aaaaaa aa aa aaaaaaa. Aaa aaaa aaaaaa a
  aaaaaaaaaa. Aaaaaa-a. (progn (set-fill-column 70) (fill-paragraph))

If I place the cursor after the last parenthesis and running eval-last-sexp, nothing changes. I expected something like the following

        10         20        30        40        50        60        70

- a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a
  a a a a a a a a a a a a a a a a a a a a a a a a

- A aaaaaa aa aa aaaaaaa. Aaa aaaa aaaaaa a aaaaaaaaaa. Aaaaaa-a.
  (progn (set-fill-column 70) (fill-paragraph))

Why does this happen? Same happens if I am on text-mode.


texts:
How to set local (per buffer) dictionary size used by aspell?
[aspell is used by my emacs as "ispell look alike"]

It can be set by --size=NN command line option of aspell.
I would like to set it via gnus-posting-styles per usenet group.


texts: Use local variable with concatenation in Org mode

texts:
I am trying to somehow use a local variable in org-mode for when I write my R code. So essentially in have this chunk that I want to automatically manage for each file.

#+BEGIN_SRC R :file /Users/ashok/Documents/plots/wtdup.png
  pairs.panels(tmpDat.cpm.log[,c(1:4,17:20)],)
#+END_SRC

in the chunk above I want to be able to replace the value for the :file with a path to the plots folder that could change. So I tried to use the local variable approach as below

 * LOCAL VARS
## Local Variables:
## mode: org
## plotfolder: "/Users/DataAnalysis/FinalAnalysisMay2016/plots"
## End:

and then replace the :file parameter with

#+BEGIN_SRC R :file (eval 'plotfolder)"/truseq_comp_logcpm_pairwise_wtdup.png"
  pairs.panels(tmpDat.cpm.log[,c(5,7,8,21:23)], )
#+END_SRC

Now when I evaluate the chunk ( after reverting my buffer to make the local variable active), the result includes only the value of the plotfolder variable and not the concatenated version as I wanted.
in this case my results would show up as

#+RESULTS
/Users/DataAnalysis/FinalAnalysisMay2016/plots

but what i really want is

#+RESULTS
/Users/DataAnalysis/FinalAnalysisMay2016/plots/truseq_comp_logcpm_pairwise_wtdup.png

If anyone has any suggestions as to how I can go about this it would be great, since then I can move the same files between machines when I am working on cleaning up the results.


texts: Customizing name of "Help" buffer opening by package-menu-describe-package

texts: Hitting RET with point on a package name in the *Packages* buffer opens a help buffer, named "Help", describing the package. RET here invokes package-menu-describe-package which in turn calls describe-package which uses with-help-buffer to create this window. How can I customize the name of this buffer?


texts: Can we do `C-c >` and `>` and `>` to continue indentation

texts:
I am using following answer to handle indentations Emacs bulk indent for Python

C-c > or C-c C-l shifts the region 4 spaces to the right

C-c < or C-c C-r shifts the region 4 spaces to the left

If I do C-c > and >; the selected text becomes >; or if I do C-c < and <; the selected text becomes <.
I was wondering can we do following:
=> C-c > , > , > to continue to indent 4 space to right one after another
=> C-c < , < , < to continue to indent 4 space to left one after another


texts: Setting syntax table leads to high CPU load

texts:
I want to set - as a word character for all reStructuredText files. In order to do this, I acted according to the wiki and added the following to my .emacs file:

(require 'misc)
(defvar my-restructuredtext-syntax-table
  (let
    ((table (make-syntax-table)))
    (modify-syntax-entry ?- "w" table)
    table))

(add-hook 'text-mode-hook
  (lambda ()
    (set-syntax-table my-restructuredtext-syntax-table)))

This loads without errors on emacs startup, but as soon as I switch to my reStructuredText containing buffer, I have 30 seconds 100 CPU usage on one core. After that emacs behaves normal and the dashes or minuses are part of words. Also when I switch buffer away from rst and back to my rst buffer it does not repeat this high CPU load behavior. Nevertheless this behavior of 30 seconds lag is quite annoying.

When I tried to hook into rst-mode the result was the same lag.

How can I add - to the word characters without this lag?

Info

GNU Emacs 24.5.1
Xubuntu 16.04.1 using XFCE


texts: notmuch doesn't show INBOX ("Spawning child process: Invalid argument")

texts:
I'm trying to get notmuch working on Windows 10 using WSL/Ubuntu. The idea is to treat the WSL as a remote machine (roughly following https://notmuchmail.org/remoteusage/) and to have a shell script that executes notmuch within the WSL. The script file looks like this (called notmuch.bat):

@echo off

bash -c "notmuch %*"

Next, I've told notmuch to use this script file with (setq notmuch-command "notmuch.bat") and also added it to the PATH variable.

When starting notmuch in emacs, I can see the correct number of mails indexed by notmuch in notmuch-hello, but when I follow the "inbox" link, no mails are shown in *notmuch-saved-search-inbox*. Instead there is the message Spawning child process: Invalid argument.

Any idea what could be causing this?


texts: Hide long GPL copyright notice at top of file

texts:
I am working with a lot of *cpp and *h files which contain a lengthy copyright notice at the beginning. I would like emacs to show these files as if this was not there, without actually removing the text.

Thas is, this:

/*
 * Copyright (C) 2006-2008 Author A
 * Copyright (C) 2006-2008 Author B
 * Copyright (C) 2006-2008 Author C
 * Copyright (C) 2006-2008 Author D
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * As a special exception, you may use this file as part of a free
 * software library without restriction. Specifically, if other files
 * instantiate templates or use macros or inline functions from this
 * file, or you compile this file and link it with other files to
 * produce an executable, this file does not by itself cause the
 * resulting executable to be covered by the GNU General Public
 * License. This exception does not however invalidate any other
 * reasons why the executable file might be covered by the GNU Library
 * General Public License.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

 #ifndef FILENAME
 #define FILENAME
 ...

should simply look like this

#ifndef FILENAME
#define FILENAME
...


texts: Is it possible to load Dired+ automatically with use-package?

texts:
I'm trying to add dired+ to my init.el with use-package but I can't seem to find the name of dired+ on any of the package repositories ( marmalade, melpa or elpa  ).

I'd been able to add dired+ after manually downloading it and activating it with require and defining the location with load-path.

Current code on init.el for loading dired+ after manually download:

;; ---- Dired + --------
;; Loads Dired+ Manually
(add-to-list 'load-path "~/.emacs.d/elpa/dired+/")
(require 'dired+)


texts: how to set truncate-lines in org-mode in spacemacs by default

texts:
Whenever I open up an .org file in spacemacs, the truncate-lines variable is set to t.

How can I make truncate-lines be set to nil by default in org-mode in the org-layer for spacemacs?

I would like lines to be wrapped in org-mode when they are about to go over the edge of the screen.

I've read different things online that talk about how to fix this problem.

One suggestion is to set the org-startup-truncated variable to nil in dotspacemacs/user-config.

I've tried doing that like this:

(defun dotspacemacs/user-config ()
  (setq org-startup-truncated nil))

However, that doesn't appear to work.  When I open up a .org file, truncate-lines is still set to t.

I've also tried adding a hook to org mode to to call spacemacs/toggle-truncate-lines-off automatically:

(defun dotspacemacs/user-config ()
  (add-hook 'org-mode-hook 'spacemacs/toggle-truncate-lines-off))

This also doesn't appear to work.  When I open up a .org file, truncate-lines is still set to t.

However, after opening a .org file, I am able to manually run the spacemacs/toggle-truncate-lines-off in order to set truncate-lines to nil.

Just in case, here is my .spacemacs file.  You can see my multiple attempts at setting truncate-lines.


texts:
I would like as said in the title customize colors of the differents levels in org-mode. I have tried from the customize-group menu then org-face but it looks like I can't change colors there.
So, I've to do it manually but what shall I add in my .init.el file ?
I've added the package color-theme and tried smth like this :

 (org-level-1 ((t (:foreground "yellow"))))

but I get the follwing error :

  Symbol's function definition is void: org-level-1

Unfortunateley I'm quite new to debugging with Emacs...Thanks in advance.


texts: replace-regexp: pattern is matching too much

texts:
I'm having problems to replace a URL inside a HTML tag with replace-regexp.

This is the original string:

This is what I want it looks like:

<img src="<?php echo foo() . '/place/foo_bar.jpg'; ?>" ... attr="..." />

The pattern that I'm using to match until now (which is matching too much):

\(http://localhost/~user/foo\.bar\)\(.+\)\("\)

And the replacing pattern:

<?php foo() . '\2'; ?>"

But this is what I'm getting:

<img src="<?php echo foo() . '/place/foo_bar.jpg" ... attr="...'; ?>" />

I thought the first group would match the base url, the second group would match the rest of the url until the double quote and the third group would match the double quote itself. But I think there is some misconception in my mind (and also in my regex) that the second group is matching until the last attribute within the html tag.

So, what is this misconception?


texts:
There are a number of commands in Emacs which apply to "words."  Examples include forward-word, kill-word, upcase-word, mark-word, transpose-words, etc.  The definition of "word" seems to vary a bit between the commands.  For example, forward-word will stop at an underscore within a word (e.g. foo_bar) but mark-word does not stop at the underscore.

Is it possible to change the definition of "word" when I am in a prog mode so that Emacs will use the appropriate word boundaries for the syntax of the current language?

When I am in c-mode I want forward-word to skip over underscores, and when I am in lisp-mode I want forward-word to skip over both hyphens and underscores, etc.


texts: If emacsclient already open, new emacsclient should "inherit" its buffer list

texts:
My workflow involves splitting frames a lot because I use i3wm. If I use the emacs native make-frame-command, the new frame will be visiting the buffer I invoked the command in. If I call emacsclient from a shell/keyboard short cut however, it default-visits the *scratch* buffer.

I'd like  emacsclient to replicate the behaviour of make-frame-command. Is this possible?


texts: Change order of symbols for «sort-lines»

texts:
I am using «sort-lines» to sort includes in C/C++ files before saving. The problem that arises is that a headers with " symbols sorted higher than ones with < symbols. But I want the reverse.

How do I change the order so, that the < character would have higher precedence than the " symbol?


texts: spacemacs - Map single evil keypress to multiple keystrokes

texts: I'm a Vim user trying out spacemacs for the first time. In Vim, I have a keybind that when I press L (jump to bottom of screen), it also centers the screen on the cursor. In my .vimrc, this is done with nnoremap L L<bar>zz <CR>, but I'm unsure of how to chain two keypresses like this in emacs.


texts: How to gracefully handle errors in init file

texts:
I would like a way to catch errors when running my init file, and then handle them gracefully. A lot of my most important customizations and keybindings show up at the end of my init file to make sure that other settings don't get applied over the top of them.  The problem is that when initialization aborts early, I feel totally crippled trying to debug the problem without my familiar key bindings and settings being applied.

Is there any way to gracefully finish out the initialization process when an error occurs?


texts:
I make a function that move from TODO state to DONE and archive it in the archives files, and I set org-mode-map to make this function by a keybinding, but in agenda it doesn't change the TODO state. I tried to find a org-agenda-mode-map or something similar but I can't find it. My function is:

(defun mark-done-and-archive ()
   (interactive)
   (org-todo 'done)
   (org-archive-subtree))
 (define-key org-mode-map "\C-c\C-x\C-s" 'mark-done-and-archive)

EDIT

So when in my TODOS.org file I hit C-c C-x C-s the todo automatically is marked as DONE and move from TODOS.org to archive.org but when I make this in org-agenda buffer the todo is moved from his file well, the only problem is that it isn't marked as done. As example:

Archive todos.org

* TODO one todo from todo.org
 * TODO Another todo

So I open todos.org and complete the first todo so I hit C-c C-x C-s and the file todos.org now contains:

* TODO Another todo

and archive.org contains:
DONE one todo from todo.org

But when I show my org-agenda and * TODO Another todo it's show, I try to complete and move to my archive file, again with C-c C-x C-s but I obtain the following in archive.org:

* DONE one todo from todo.org
 * TODO Another todo

and todos.org it's empty.


texts: Seeing file names in TODO entries when using org-attach

texts: I use org-attach mostly to "move" files and store them under various TODO items. I find this an invaluable feature for keeping receipts and other important documents. The limitation of org-attachments is that there is no way of knowing what files are kept under the item just by looking at the entry. Org uses the keyword :ATTACH: to indicate that that entry has an attachment. One can also tell this by the fact that there is an ID generated under properties. It would however be a nice feature to be able to see at least the filenames one has under that entry, without having to actually call org-attach.


texts:
I am trying to disable the underscore thing in ESS where it gets converted to a <- . If I add

(add-hook 'ess-mode-hook
   (lambda ()
      (ess-toggle-underscore nil)))

To my init file, it works for the first R file I open, but as soon as I open a second R file, the behavior is back there. Is there anyway to completely disable this?


texts: Wrapping Python code with %cpaste and -- to send to iPython in elpy

texts:
I am loving my elpy setup in emacs, but I have one question.  When I put in a ipdb.set_trace() for the ipython shell I want to send code snippets to the iPython shell.  Right now my workaround is using the isend minor mode to highlight my code and send it to the iPython shell.  The problem is that I kept getting IndentationError.  Now, I can just put a %cpaste and -- before and after my highlighted code and hit control-enter to send it to the ipython shell and run it.

My question is, is there a way to write a wrapper around the isend command so that it automatically adds the %cpaste in front of the highlighted code,  and a -- after it when sending it to the iPython shell?

I think it might even be a cool feature to add to the elpy package.


texts: Is there a simple way to "drop" scores from a mean function in org-mode?

texts:
I have an org table:

| Student | Score 1 | Score 2 | Score 3 | Score 4 | Score 5 |   Mean | Mean (Lowest Two Dropped) |
|---------+---------+---------+---------+---------+---------+--------+---------------------------|
| John    |    5.74 |   84.43 |    8.32 |   46.71 |   37.94 | 36.628 |                           |
| Paul    |   70.13 |   83.51 |   85.95 |    8.78 |   55.53 |  60.78 |                           |
| George  |   66.28 |   20.80 |    2.63 |   69.76 |   46.85 | 41.264 |                           |
| Ringo   |   50.93 |   66.09 |   44.76 |   19.50 |   16.32 |  39.52 |                           |
#+TBLFM: @2$7..@>$7=vmean($2..$6)

Column 1 lists a student. Columns 2-6 list each student's score on an assignment.

The code vmean($2..$6) can be used to compute each student's average score on all five assignments.

I'd like to be generous to my students and drop the lowest n scores (in this case n=2). I'm having trouble figuring out how to accomplish this.

Is there a simple way to drop the lowest n scores for each student and take the new average?


texts: How to write a function which toggles between the executions of two other functions?

texts:
Suppose that we have two functions foo1 and foo2. I would like to write a third function foo3 in such a way that the first execution of foo3results in the execution of foo1, the second execution of foo3 results in the execution of foo2 and so on (i.e. the nth execution of foo3 results in the execution of foo1 if n is odd, and results in the execution of foo2 if n is even).

Is this possible?


texts: Interactive input, strings and quoted items

texts:
(defun ecli-metadata-single (ecli meta)
  "meta needs to be quotes \n example: (case-metadata ECLI:NL:HR:2013:BY6108 'identifier)"
  (interactive "sEnter ecli: \nxEnter identifier: ")
  (insert (car (cddr (assoc  meta (ecli-metadata-full ecli)))))
 )

(ecli-metadata-single "ECLI:NL:HR:2007:BA2511" 'date)

What this code does is getting some metadata from a remote xml-file. The code seems to work fine when I use just type the expression, however, the interactive version does not insert the data, instead throwing an error saying

  wrong type argument: char-or-string-p, nil.

I have looked up (interactive) in C-h f, and tried many of the alternative characters for input. However, I still get the same (non-)result. After browsing stack-overflow and not finding a suitable answer, I 'gave up' and decided to ask this question.

To recap:

My goal is to make the above function interactively insert data. The first argument is an identifier-code, and the second argument is the data I want from the retrieved xml (other code not shown due to length). The first argument is a string "ECLI:NL:HR:2013:BY6108", and the second argument is a quoted item 'date.

A second question would be how I can remove the required quote from the input-arguments. I have tried something like (quote meta), but that did not work.


texts: is it possible for two people, using different emacs and keybindings to edit the same file synchronously?

texts: I want to pair program with a couple of people but my keybindings in emacs are not the same as theirs. Is there a way to edit the same file but keep the keybindings different?


texts: How do I set cursor colours per evil-state in the (non-GUI) text terminal?

texts: In the terminal, (set-cursor-color "red") has no effect, so the only way I can distinguish insert from normal mode under evil-mode is through the <N> or <I> on the modeline. Is there a way to set the cursor colour even in text terminals? (I use sakura with TERM=xterm-256color if that matters.)


texts: Org mode - storing LaTeX preview files in a separate directory

texts:
Let's say I am working with "file_name.org" file. When I use C-c C-x C-l to generate a LaTeX preview, it creates a png image and store in ltximg/ directory by default.

I would store the preview images per file. So I want C-c C-x C-l
 to create a directory (if there isn't one) ltximg/file_name/ and store the image there.

I know that I have to manipulate org-preview-latex-image-directory variable, but I am not sure how. Could someone help me with this?

Update

I defined the following function. This works changes the org-preview-latex-image-directory whenever an org file is opened. So if I am working with multiple org files, it gets confused. So I am trying to write a wrapper for org-toggle-latex-fragment function so that whenever org-toggle-latex-fragment is called, latex-image-directory function is called. But I am having some trouble implementing the argument, e.g., C-u C-c C-x C-l.

(defun latex-image-directory ()
  (require 'cl-lib)
  (setq file-name (nth 0 (last (split-string (buffer-file-name) "/"))))
  ;; slice the last 4 characters: ".org"
  (setq org-preview-latex-image-directory (concat "ltximg/"
(cl-subseq file-name 0 -4) "/"))
)